SanityCheckPlan fails after ProjectionPushdown for GROUP BY over a mark join on a struct field (regression from #26747)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 20/100
調査の方向性
Start by tracing the equivalence handling described in the issue through EnsureRequirements and the ProjectionPushdown physical optimizer rule, then inspect the related regression tests around #26747. Reproduce the SQL query from the issue and check how the join’s output partitioning is represented after projection pushdown. Done means the query plans and returns a and b without the final sanity check rejecting its distribution requirements.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
This query fails to plan on main:
SET datafusion.execution.target_partitions = 2;
SET datafusion.optimizer.hash_join_single_partition_threshold_rows = 0;
COPY (SELECT named_struct('k', 'a') AS s) TO 'data/t/1.parquet';
COPY (SELECT named_struct('k', 'b') AS s) TO 'data/t/2.parquet';
CREATE EXTERNAL TABLE t STORED AS PARQUET LOCATION 'data/t/';
SELECT s['k'] FROM t WHERE s['k'] = 'a' OR s['k'] IN (SELECT s['k'] FROM t) GROUP BY 1;
SanityCheckPlan: order and distribution requirements stopped holding after physical optimizer rule 'ProjectionPushdown'
caused by
Error during planning: Plan: [
AggregateExec: mode=SinglePartitioned, gby=[__datafusion_extracted_2@0 as __datafusion_extracted_2], aggr=[]
FilterExec: __datafusion_extracted_3@1 = a OR mark@0, projection=[__datafusion_extracted_2@2]
ProjectionExec: expr=[mark@0 as mark, get_field(s@1, k) as __datafusion_extracted_3, get_field(s@1, k) as __datafusion_extracted_2]
HashJoinExec: mode=Partitioned, join_type=LeftMark, on=[(__datafusion_extracted_4@0, t.s[k]@0)], projection=[mark@2, s@1]
RepartitionExec: partitioning=Hash([__datafusion_extracted_4@0], 2), input_partitions=2
DataSourceExec: file_groups={...}, projection=[get_field(s@0, k) as __datafusion_extracted_4, s], file_type=parquet
RepartitionExec: partitioning=Hash([t.s[k]@0], 2), input_partitions=2
DataSourceExec: file_groups={...}, projection=[get_field(s@0, k) as t.s[k]], file_type=parquet
] does not satisfy distribution requirements: KeyPartitioned[[__datafusion_extracted_2@0]]). Child-0 output partitioning: Hash([__datafusion_extracted_4@0], 2)
The settings make the join Partitioned on this small data set.
Expected behavior
The query returns a and b, as it does at 0d3aac0bde.
Additional context
A bisect points to #26747 (99e723dd47). Its parent ce0e8293f9 plans the query.
#26747 records get_field(s, k) ≡ __datafusion_extracted_4 when projecting equivalences. That lets EnsureRequirements use the join's hash partitioning for the group key and skip a repartition, which is correct. Then ProjectionPushdown moves get_field(s, k) into the DataSourceExec projection and drops __datafusion_extracted_4 through the join's embedded projection. Neither step records the equivalence again. So the join's output partitioning becomes an unknown column, and the final check rejects the plan.
No rows move in that rewrite, so the query fails to plan and never returns wrong results.
Claude Code (an AI coding assistant) investigated this and wrote this issue on behalf of cetra3. A PR with a fix follows.
- 主要言語
- Rust
- スター
- 9.6k
- フォーク
- 2.6k
- 平均マージ
- 3日 4時間
- マージ済み PR(30日)
- 345
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/datafusion のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/datafusion#27315 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/datafusion#27094 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yaml対応中かも @jonasHanhan が 9 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/datafusion#27059 ·
メンテナーはふだん 1 日以内に返信
-
`ProjectionExprs::project_statistics` computes approximate `Statistics::total_byte_size` ignoring column stats対応中かも @joseph-isaacs が 10 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/datafusion#27050 ·
メンテナーはふだん 1 日以内に返信
-
physical-plan: decoding an Unnest or Explain node with an unset field panics対応中かも @geoHeil が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apache/datafusion#26999 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
apache/datafusion の issue をすべて見る
似ている issue
-
area:schema documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ElectronicWave/Elemental#252 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dekobon/big-code-analysis#1887 ·
メンテナーはふだん 1 日以内に返信
-
Shell中文符号输入异常オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信