Skip to content

Fix logical error in ReadFromMerge::addFilter when child plan is not initialized#95047

Merged
alexey-milovidov merged 2 commits intomasterfrom
fix-merge-table-filter-push-down-uninitialized-plan
Jan 24, 2026
Merged

Fix logical error in ReadFromMerge::addFilter when child plan is not initialized#95047
alexey-milovidov merged 2 commits intomasterfrom
fix-merge-table-filter-push-down-uninitialized-plan

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

@alexey-milovidov alexey-milovidov commented Jan 24, 2026

In ReadFromMerge::addFilter, when iterating over child_plans to propagate a filter, the code called getCurrentHeader() without checking if the plan was initialized. Child plans can be uninitialized because createPlanForTable returns an empty ChildPlan when storage->read() doesn't initialize the plan.

This caused a "QueryPlan was not initialized" exception found by the AST fuzzer with the following query:

SELECT explain FROM (SELECT * FROM viewExplain('EXPLAIN', '', (
    SELECT count() FROM foo_merge INNER JOIN t2 USING (Val)
    SETTINGS enable_join_runtime_filters = 1, parallel_replicas_local_plan = 1
)))

See https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=637b383d0c472f3cb3df4371274c9b9c390b3785&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_ubsan%29&name_1=AST%20fuzzer%20%28amd_ubsan%29

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

alexey-milovidov and others added 2 commits January 24, 2026 17:40
…itialized

In `ReadFromMerge::addFilter`, when iterating over `child_plans` to
propagate a filter, the code called `getCurrentHeader()` without
checking if the plan was initialized. Child plans can be uninitialized
because `createPlanForTable` returns an empty `ChildPlan` when
`storage->read()` doesn't initialize the plan.

This caused a "QueryPlan was not initialized" exception found by the
AST fuzzer with the following query:
```
SELECT explain FROM (SELECT * FROM viewExplain('EXPLAIN', '', (
    SELECT count() FROM foo_merge INNER JOIN t2 USING (Val)
    SETTINGS enable_join_runtime_filters = 1, parallel_replicas_local_plan = 1
)))
```

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh Bot commented Jan 24, 2026

Workflow [PR], commit [8ab3e5b]

Summary:

job_name test_name status info comment
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting: the query: (STID: 1941-1bfa) FAIL cidb, issue
BuzzHouse (arm_asan) error

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jan 24, 2026
@alexey-milovidov
Copy link
Copy Markdown
Member Author

The test successfully reproduces the issue on the debug build: https://pastila.nl/?004b0bb8/658891c0b623d91f48d541203783472f#GRdNrf2XU7N4e5SJYiTuoA==GCM

@alexey-milovidov alexey-milovidov merged commit a7a87eb into master Jan 24, 2026
129 of 134 checks passed
@alexey-milovidov alexey-milovidov deleted the fix-merge-table-filter-push-down-uninitialized-plan branch January 24, 2026 23:08
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants