Repository navigation
Support distributed execution of plans with a CreatingSets step - #113826
Conversation
…`IN`-subquery baseline Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
…ng index-retention path Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
…set build Co-Authored-By: Claude Fable 5 <[email protected]>
…distributed_plan` Co-Authored-By: Claude Fable 5 <[email protected]>
…rializing a plan
|
Workflow [PR], commit [263a1a1] Summary: ✅
AI ReviewSummaryThis PR switches Findings❌ Blockers
Tests
Final VerdictRequest changes. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 290/330 (87.88%) · Uncovered code |
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=5 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
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. Object file sizes509 object files changed (+396.08 KiB total), 2 added.
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units766 translation units recompiled, 2668 s compile time in total, 295 of them have a recent master baseline. Translation units without a recent master baseline:
|
… end-of-data Co-Authored-By: Claude Fable 5 <[email protected]>
| /// added here and expanded the ordinary way, so this pipeline builds them before the | ||
| /// distributed source sends the worker tasks with their values. The cache is skipped: | ||
| /// a cached set has no values. | ||
| bool has_sets_to_build = false; |
There was a problem hiding this comment.
optimize() now returns before resolveMaterializingCTEs(), but the multi-stage make_distributed_plan path never adds an initiator-side replacement for those delayed CTE writers the way it does for delayed sets here. That leaves any WITH ... AS MATERIALIZED referenced by the main query or by one of these shipped IN subqueries without a MaterializingCTEsStep: fragment serialization strips DelayedMaterializingCTEsStep entirely, and the first ReadFromMemoryStorageStep then hits the fail-fast "Reading from materialized CTE ... before its materialization completed" exception instead of seeing populated storage.
We need to preserve and resolve delayed materialized CTEs alongside the delayed sets before the distributed source starts sending worker tasks.
…ducer Co-Authored-By: Claude Fable 5 <[email protected]>
…d-plan sets Co-Authored-By: Claude Fable 5 <[email protected]>
| rhs_type = std::make_shared<DataTypeTuple>(rhs_tuple->getElements()); | ||
|
|
||
| if (!lhs_type->equals(*rhs_type)) | ||
| throw Exception(ErrorCodes::INCORRECT_DATA, |
There was a problem hiding this comment.
I would be happy to avoid this change, it possible.
There was a problem hiding this comment.
Created a follow-up PR to test an alternative fix #114229
| return plan; | ||
| } | ||
|
|
||
| void FutureSetFromSubquery::prepareForDistributedPlan(const ContextPtr & context) |
There was a problem hiding this comment.
Maybe we can consider adding a setting: fill sets on the initiator always, or send as a plan, when possible.
There was a problem hiding this comment.
This seems to be tricky in case of non-deterministic sub-queries that might return different results on for execution on different workers. Also the decision to when to execute the sub-query ideally should be driven by cost based optimizer. So I would prefer to support simple logic for now and extend it later in follow-ups
Related: #109476, #83991
Support distributed execution of plans with a
CreatingSetsstep. Until nowmake_distributed_planworked around the missing support by force-enablingrewrite_in_to_join, overriding the user's explicit setting.The set subquery now executes once on the initiator, the same way local execution and
GLOBAL INbuild sets: during planning when index analysis requests the set, otherwise in the initiator pipeline at query start, gated before the distributed source sends the worker tasks. The subquery itself runs as a distributed plan when it can be serialized, with deduplication on the workers; otherwise it builds locally on the initiator. The initiator uses the set for index analysis, and the set values ship with the worker tasks as the existingTupleValuesrecord, so the workers can evaluate theINfilter. TheGLOBAL INtransfer limits (max_rows_to_transfer/max_bytes_to_transfer, unlimited by default) also bound the shipped set. An over-limit set and a set backed by an external table fail the query with a clear error.The forced
rewrite_in_to_joinoverride is removed. The rewrite remains available as an explicit setting: convertingINto a join lets the optimizer reorder joins across the whole query, which can produce more optimal plans for complex queries. The opposite rewrite,query_plan_convert_join_to_in, is not applied undermake_distributed_plan: the set it creates uses its own NULL-matching policy (transform_null_in = false), which the shipped set record does not carry, so a worker would rebuild the set with different membership.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Support distributed execution of query plans with
IN (subquery)without rewriting it to aJOIN. The set is built once on the initiator and its values are shipped with the worker tasks. The forcedrewrite_in_to_joinoverride is removed; the rewrite remains available as an explicit setting.Version info
26.8.1.1119(included in26.8and later)