Repository navigation
Fix filter pushdown through JOINs inside VIEWs with the analyzer - #100392
alexey-milovidov wants to merge 4 commits into
Conversation
When querying a VIEW that contains a JOIN over local MergeTree tables, the outer WHERE clause was not pushed down to the underlying tables. The root cause: `collectFiltersForAnalysis` only runs the filter collection pipeline for specific storage types (Distributed, parallel replicas MergeTree, ObjectStorageCluster, StorageView). When a VIEW's inner query contains only plain MergeTree tables, the function returned early, discarding the `post_filter` (the outer WHERE clause pushed from `StorageView::read`). The fix ensures the filter collection pipeline always runs when a `post_filter` is provided, enabling the plan optimizer to push the filter through the JOIN to individual tables. Closes #67668 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Workflow [PR], commit [6b2beb3] Summary: ✅ AI ReviewSummaryThis PR fixes predicate pushdown for queries over ClickHouse Rules
Final Verdict
|
Three issues causing CI failures: 1. Background merges could merge `data_user_utm` parts (no partition key, both inserts land in the same partition), changing Parts: 1/2 to Parts: 1/1. Fix: `SYSTEM STOP MERGES` before inserting data. 2. Distributed plan CI mode sets `serialize_query_plan = 1`, which changes EXPLAIN output format. Fix: explicitly set `serialize_query_plan = 0`. 3. Random MergeTree settings (e.g. `add_minmax_index_for_numeric_columns`) could add extra index steps to the EXPLAIN output. Fix: add `no-random-merge-tree-settings` tag. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 100.00% (6/6, 0 noise lines excluded) |
KochetovNicolai
left a comment
There was a problem hiding this comment.
The test does not reproduce the failure for me (on a branch without the fix).
I will take a look.
|
I've tried hard but could not reproduce the initial issue. |
When querying a VIEW that contains a JOIN over local MergeTree tables, the outer WHERE clause was not pushed down to the underlying tables.
The root cause:
collectFiltersForAnalysisonly runs the filter collection pipeline for specific storage types (Distributed, parallel replicas MergeTree, ObjectStorageCluster, StorageView). When a VIEW's inner query contains only plain MergeTree tables, the function returned early, discarding thepost_filter(the outer WHERE clause pushed fromStorageView::read).The fix ensures the filter collection pipeline always runs when a
post_filteris provided, enabling the plan optimizer to push the filter through the JOIN to individual tables.Closes #67668
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Improve performance of reading from VIEWs containing JOINs. Closes #67668.