SanityCheckPlan fails after ProjectionPushdown for GROUP BY over a mark join on a struct field (regression from #26747)

未关闭
#27,318 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@cetra3 已经在做这个了。

开始于 2026年11月11日。

  • #27319 来自 @cetra3 —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
20/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
rust, sql
领域
backend, databases

调研方向

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 小时
30 天内合并 PR
345

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/datafusion 的其他 Issue

查看 apache/datafusion 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。