apache / apache/datafusion

Rewrite UDAF reversed expression name

オープン
#11,629 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Rust
スター
9.3k
フォーク
2.4k
平均マージ
3日 11時間
マージ済み PR(30日)
360

説明

I think it would be good to eventually move this to a method in `https://github.com/apache/datafusion/pull/11611` though I agree this is good for now. Maybe we can file a ticket to track

_Originally posted by @alamb in https://github.com/apache/datafusion/pull/11611#discussion_r1688699754_

I think we could extend to rewrite the whole expression name, and it could be more straightforward what the name is rewritten

```rust
let mut name = self.name().to_string();
// If the function is changed, we need to reverse order_by clause as well
// i.e. First(a order by b asc null first) -> Last(a order by b desc null last)
if self.fun().name() == reverse_udf.name() {
} else {
replace_order_by_clause(&mut name);
}
replace_fn_name_clause(&mut name, self.fun.name(), reverse_udf.name());
```

Something like
```rust
let mut name = self.name().to_string();
name = self.fun.reverse_name(name)
```

Add `reverse_name` in `AggregateUDFImpl`

```rust
trait AggregateUDFImpl {
fn reverse_name(&self) -> String {
...
}
}
```

Specificially we need to rewrite name for First/Last. For array_agg, the name should be the same.

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

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

調査の方向性

まず、replace_order_by_clause と replace_fn_name_clause を呼び出している既存の反転式処理を見つけ、次に AggregateUDFImpl と First、Last、array_agg の実装を読みます。reverse_name が式名の書き換えを一元化し、First と Last が正しい反転名を生成し、array_agg が名前を変更せずに維持すれば、変更は完了です。

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

評価

技術スタック
rust
領域
databases
issue の種類
リファクタリング
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

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

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