Add most functions to the Expr class so that they're chainable.
まだ誰も着手していません。
評価
調査の方向性
まず Expr クラスと issue で参照されている functions モジュールから始め、既存の Expr メソッドと、式を入力として受け取る関数を比較します。該当する関数にチェーン可能なメソッドを追加しつつ、functions モジュールの API は維持してください。完成時には、示されている col("id1").abs().alias("id1") パターンと複数入力の例が機能するようにします。
索引モデルが issue の本文から書いたものです。
説明
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
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/datafusion-python のほかの issue
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/datafusion-python#1726 ·
-
難易度 2/5 半日 初心者へのやさしさ 88/100
apache/datafusion-python#1691 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/datafusion-python#1644 ·
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
apache/datafusion-python#1737 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
apache/datafusion-python#1735 · コメント 1 件 ·
apache/datafusion-python の issue をすべて見る
似ている issue
-
documentation help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
simonw/sqlite-utils#872 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100