Rewrite UDAF reversed expression name
- Vorherrschende Sprache
- Rust
- Sterne
- 9.3k
- Forks
- 2.4k
- Ø Merge
- 3 T. 11 Std.
- Gemergte PRs (30 T.)
- 362
Beschreibung
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.
Beitragsleitfaden
Rechercherichtung
Beginne damit, die bestehende Verarbeitung umgekehrter Ausdrücke zu finden, die replace_order_by_clause und replace_fn_name_clause aufruft, und lies anschließend AggregateUDFImpl sowie die Implementierungen von First, Last und array_agg. Die Änderung ist abgeschlossen, wenn reverse_name die Umschreibung von Ausdrucksnamen zentralisiert, First und Last die korrekten umgekehrten Namen erzeugen und array_agg seinen Namen unverändert beibehält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- rust
- Bereich
- databases
- Issue-Typ
- Refactoring
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100