Rewrite UDAF reversed expression name
- Lenguaje dominante
- Rust
- Estrellas
- 9.3k
- Forks
- 2.4k
- Merge medio
- 3 d 11 h
- PR fusionados (30 d)
- 360
Descripción
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.
Guía de contribución
Línea de trabajo
Comienza localizando el manejo existente de expresiones invertidas que llama a replace_order_by_clause y replace_fn_name_clause; después, lee AggregateUDFImpl y las implementaciones de First, Last y array_agg. El cambio estará completo cuando reverse_name centralice la reescritura de nombres de expresiones, First y Last produzcan los nombres invertidos correctos y array_agg mantenga su nombre sin cambios.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rust
- Área
- databases
- Tipo de issue
- Refactorización
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100