Add most functions to the Expr class so that they're chainable.

オープン
#1,064 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
42/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
data

調査の方向性

まず Expr クラスと issue で参照されている functions モジュールから始め、既存の Expr メソッドと、式を入力として受け取る関数を比較します。該当する関数にチェーン可能なメソッドを追加しつつ、functions モジュールの API は維持してください。完成時には、示されている col("id1").abs().alias("id1") パターンと複数入力の例が機能するようにします。

索引モデルが issue の本文から書いたものです。

説明

enhancement

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Instead of doing

df.select(
    F.abs(
        col("id1")
        )
    .alias("id1")
    )

It would be nicer to do

df.select(
    col("id1")
    .abs()
    .alias("id1")
    )

Describe the solution you'd like
This is already partly there, for example, alias is already in the Expr class. It would be a bit tedious but easy to add under class Expr, for example:

def abs(self) -> datafusion.Expr:
    """Return the absolute value of a given number.

    Returns:
    --------
    Expr
        A new expression representing the absolute value of the input expression.
    """
    return F.abs(self)

Describe alternatives you've considered
if it weren't for the type hinter, monkey patching.

Additional context
There will still be functions that don't make sense to chain off of a call to col such as when since it doesn't return an Expr. But, even functions that take multiple inputs can have this for instance col("a").atan2("b"). Additionally, this is completely backwards compatible since I'm not proposing eliminating the functions module.

主要言語
Python
スター
605
フォーク
176
平均マージ
1日 23時間
マージ済み PR(30日)
8

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/datafusion-python のほかの issue

apache/datafusion-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。