Avoid re-evaluating expressions in filters and projections
- Vorherrschende Sprache
- Rust
- Sterne
- 9.3k
- Forks
- 2.4k
- Ø Merge
- 3 T. 11 Std.
- Gemergte PRs (30 T.)
- 362
Beschreibung
This patterns shows up pretty often:
```sql
select expensive(col)
from t
where expensive(col)
```
A pathological case is variant / json:
```sql
select variant_get(col, 'key')
from t
from variant_get(col, 'key')
```
There's two issues here:
1. Until we solve projection pushdown (https://github.com/apache/datafusion/issues/14993) if `key` is not shredded we materialize the entire `col` and then extract `key` in a `ProjectionExec`.
2. Even once that is resolved, or in the case that `key` is not shredded evaluating `variant_get(col, 'key')` itself is expensive we still re-compute `variant_get(col, 'key')` twice: once for the filter and once for the projection.
Beitragsleitfaden
Rechercherichtung
Beginne damit, das in den SQL-Beispielen beschriebene Verhalten von Filterung und Projektion zu lesen, einschließlich ProjectionExec und des Problems zur Projection-Pushdown #14993. Ermittle, wie wiederholte Ausdrücke wie variant_get(col, 'key') dargestellt und ausgewertet werden, und definiere anschließend die Fertigstellung als das Vermeiden doppelter Auswertung bei gleichzeitiger Beibehaltung der Abfrageergebnisse.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- rust, sql
- Bereich
- data-engineering, databases
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100