Repository navigation
Conversation
|
Workflow [PR], commit [68726c9] Summary: ✅
AI ReviewSummaryThis PR extends Findings❌ Blockers
Tests
Final Verdict❌ Changes requested. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 29/31 (93.55%) · Uncovered code |
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 62/64 (96.88%) · Uncovered code |
| /// Merging a condition whose operands have different types adds a cast that makes the key `_CAST(key, ...)`. | ||
| /// This can make prepared join storage fail because it no longer recognizes the key. | ||
| const bool require_equal_types = child_node->children.size() == 2 | ||
| && typeid_cast<JoinStepLogicalLookup *>(child_node->children.back()->step.get()) != nullptr; |
There was a problem hiding this comment.
We can reject joins with StorageJoin on the right side in the beggining of functions. We should not merge condition into the JOIN in such a case.
There was a problem hiding this comment.
I allowed StorageJoin with equal types here because otherwise the following query shape that works now will start failing.
But I'm not sure if such a query is intended usage, WDT?
There was a problem hiding this comment.
I think it is not intended and we should not allow this optimisation for StorageJoin. There is another example:
SELECT * FROM left l JOIN right r ON 1 WHERE l.id = r.id AND l.tag = r.tag SETTINGS query_plan_merge_filter_into_join_condition = 1;
If tag columns will have different types, it will fail with too many keys. It is impossible to implement it consistent for StorageJoin, so we should not allow it.
There was a problem hiding this comment.
that makes sense, I switched to rejecting JoinStepLogicalLookup at the start.
|
|
||
| /// Merging a condition can make a prepared join storage fail because it no longer recognizes the key. | ||
| auto is_storage_join = child_node->children.size() == 2 | ||
| && typeid_cast<JoinStepLogicalLookup *>(child_node->children.back()->step.get()) != nullptr; |
There was a problem hiding this comment.
This guard now disables mergeFilterIntoJoinCondition for every JoinStepLogicalLookup, not only for StorageJoin. That is broader than the bug it is fixing: dictionaries and other IKeyValueEntity lookups also arrive here via JoinStepLogicalLookup, and master already relies on this pass for valid equal-type queries of the form ... INNER JOIN dict ON 1 WHERE lhs.pk = rhs.pk.
Before this return, the WHERE equality was extracted here, buildPhysicalJoinImpl could still discover one join key, and tryDirectJoin was able to pick DirectKeyValueJoin (src/Processors/QueryPlan/JoinStepLogical.cpp:1430-1464, src/Planner/PlannerJoins.cpp:1048-1121). With the unconditional early exit, the same query keeps ON 1, no keys are found, and the planner falls through to the constant/cross path instead of a keyed lookup join. That regresses an existing direct/dictionary plan into a full-scan ConstantJoin.
Can we narrow this guard to the unsafe prepared-storage cases (at least prepared_join_storage.storage_join) and add a focused regression test for a dictionary/EmbeddedRocksDB query shaped as ON 1 WHERE lhs.pk = rhs.pk?
There was a problem hiding this comment.
the same discussion in #112630 (comment) applies to this.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units14 translation units recompiled, 76 s compile time in total, 14 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.13 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
…ack cases Review feedback pointed out that under the default `query_plan_merge_filter_into_join_condition = 1` the guarded float cases' fallback loses the `-0.0` matches, so pinning the setting looked like hiding a gap. The divergence reproduces with the substitution disabled — it is master's own decorrelation fallback interacting with the common-supertype condition merging, now tracked as issue #116358 (caused by PR #112630, the fix belongs in `tryMergeFilterIntoJoinCondition`, not in the decorrelation). The pin stays for test determinism; the pin comment and the case 12/24 headers now reference the tracked issue instead of implying the `equals` fallback semantics are the production default. Related: #116358 Related: #115493 Co-Authored-By: Claude Fable 5 <[email protected]>
… condition The join cost model counts every column equivalence class that spans a join step (`computeSelectivity`), but `cleanupJoinPredicates` added the transitive equality only to a step without a condition of its own. A step with an unrelated condition was costed with the class and executed without it. TPC-H Q02 hits this since ClickHouse#112630: the `WHERE` equality on the minimal supply cost is merged into the join, so with `dpsize` (and `dphyp,greedy`, `dpsub,greedy`) the decorrelated subquery is joined to `partsupp` on the supply cost alone, and every subquery row matches about |partsupp| / NDV(ps_supplycost) rows until the part key is applied three joins later. 26.8 joined this step on the part key. Phase 2 now runs at every inner step and adds one equality per class that spans both sides and is not connected by the step's own conditions yet. With conditions present it skips classes whose members differ in type beyond Nullable/LowCardinality (`String = FixedString` is not transitive) and steps with a prepared-storage side (`Join` engine, key-value storage), which is looked up by its declared key only (an extra key fails with `Code: 264`). The join order is unchanged, and Phase 1 still removes the later duplicate. In 03836 only Q02 changes: `partsupp` and the subquery are now shuffled by `ps_partkey` instead of broadcasting the subquery. Closes ClickHouse#122396 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Currently
mergeFilterIntoJoinConditiononly applies when both sides of the condition have the same type.This PR relaxes the condition to be consistent with
predicateOperandsToCommonType:allow_dynamic_type_in_join_keysis trueThis is especially useful for the case where one side is nullable and the other isn't.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A
WHEREequality is now merged into theJOINcondition when its operands have different types but a common supertype, such asInt32andNullable(Int32). This allows a CROSS join to be converted to an INNER Join.Workflow [PR]
Sync PR [sync-upstream/pr/112630]
Version info
26.9.1.23(included in26.9and later)