apache / apache/datafusion

Avoid re-evaluating expressions in filters and projections

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

説明

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.

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

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

調査の方向性

まず、SQL の例で説明されているフィルターとプロジェクションの動作を読み、ProjectionExec と projection-pushdown の issue #14993 も確認します。variant_get(col, 'key') のような繰り返し式がどのように表現され、評価されるかを判断し、そのうえで、クエリ結果を維持しながら重複した評価を避けることを完了条件として定義します。

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

評価

技術スタック
rust, sql
領域
data-engineering, databases
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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