Repository navigation
Disjunctions pushdown for JOINs - #84735
Conversation
|
Workflow [PR], commit [9055c78] Summary: ❌
|
This comment was marked as resolved.
This comment was marked as resolved.
davenger
left a comment
There was a problem hiding this comment.
Please remove these debug prints
|
@yariks5s Can we add the new setting in the |
|
@rschu1ze We definitely can because this setting should not change the result of queries, but we need to isolate this setting from the tests that perform I will do it in the follow-up PR, thank you. |
|
PR for reference: #87697 |
| new_filter_node.step = std::make_unique<FilterStep>( | ||
| input_header, | ||
| std::move(filter_dag), | ||
| filter_column_name, | ||
| true); |
There was a problem hiding this comment.
Here we have to make sure the order of outputs is the same as before, because in JoinStepLogical we have the assumption that the order of inputs in the dag are following the order of inputs in the input headers. Furthermore, int the test you added this optimization changes the order in the output header, thus the input header of the join step is different than the filter step, which is problematic.
The `onlyDependsOnAvailableColumns` function in the partial predicate push-down for JOINs did not check for `ARRAY_JOIN` nodes. This caused predicates containing `arrayJoin` to be incorrectly pushed down below a JOIN as a partial (speculative) filter, while the original filter above the JOIN was kept. The `arrayJoin` therefore executed twice -- once in the pushed-down filter and once in the original filter -- producing duplicate rows. The fix rejects any subgraph containing `ARRAY_JOIN` from being considered for partial predicate push-down. The bug was introduced in #84735 and exposed when the optimization was enabled by default in #89313. Closes #96398 Co-Authored-By: Claude Opus 4.6 <[email protected]>
A new logic, which pushes safe OR-branches of filters above a JOIN down to the left/right inputs so storages can pre-filter earlier. It works when every top-level OR branch contributes at least one deterministic predicate for the target side (e.g., (
t1.k IN (1,2) AND t2.x=100) OR (t1.k IN (3,4) AND t2.x=200)pushest1.k IN (1,2,3,4)to the left andt2.x IN (100,200)to the right). It does not apply if some branch lacks a predicate for that side (e.g., (t1.a=1 AND t2.b=2) OR (t1.a=3)can’t push to t2) or for non-AND/OR forms, and the original filter remains to preserve results. Used under theuse_join_disjunctions_push_downsetting.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Provides a logic regarding pushing down the disjunction JOIN predicates. Example: in TPC-H Q7 for a condition on 2 tables n1 and n2 like
(n1.n_name = 'FRANCE' AND n2.n_name = 'GERMANY') OR (n1.n_name = 'GERMANY' AND n2.n_name = 'FRANCE')we extract separate partial filters for each tablen1.n_name = 'FRANCE' OR n1.n_name = 'GERMANY'for n1 andn2.n_name = 'GERMANY' OR n2.n_name = 'FRANCE'for n2.