Repository navigation
Add the query fragment graph model for a fragment-aware EXPLAIN of distributed plans - #124600
Conversation
|
Workflow [PR], commit [6dfdaae] Summary: ✅
AI ReviewSummaryThis PR introduces the internal Missing context / blind spots
Tests
Final VerdictStatus: |
Build profile diff (arm_release)Commit See the job log for details. |
antoniofilipovic
left a comment
There was a problem hiding this comment.
LGTM, thanks! As I understand this is a machinery for later steps to create fragment graph from real distributed plan, right?
2ad32ae
Related: #112738
Related: #124179
First of a series of pull requests that teach
EXPLAINabout the stages of a query planned withmake_distributed_planand executed on stateless workers. The design is in the RFC above.For now we only create the FragmentGraph and output in the format below for test and validation only:
Motivation
EXPLAIN PLANtoday prints the single logical tree withShuffleExchange,BroadcastExchangeandGatherExchangesteps inside it.The model
src/Processors/QueryPlan/Fragments/FragmentGraph.hdefines a value object built from aDistributedQueryPlan:QueryFragment: one stage, with its id, the executor's stage name for joins with logs and traces, the role (InitiatororWorker), the execution location (Distributedfor a stage run as tasks,SingleNodefor a plan that was not cut and runs as one pipeline on the initiator, with its fallback reason), an optional description (e.g. the set the fragment fills), the number of tasks, itschildren(the ids of the exchanges it reads) and a pointer to the stage's plan.FragmentExchange: the edge between two fragments. Every dependency goes through exactly one exchange, so the exchange carries the dependency too: the executor'sexchange_Nname, the producer and consumer fragments, the kind (Hash,Broadcast,Gather,Any, andSetValuesfor a built set shipped inside the reader's tasks), the keys or the merge order, the mode (PipelinedorMaterialised), the bucket counts, whether it isStreamingorBlockingwith the reason (e.g. "build side of JoinLogical" or "set must be complete"), andExchangeStatisticswith the estimated rows (actual values come withEXPLAIN ANALYZElater).FragmentGraph: fragments and exchanges sorted by id. A plan that was not distributed is the degenerate graph of oneSingleNodefragment carrying the fallback reason.validateFragmentGraphthrowsLOGICAL_ERRORunless every child of a fragment is an exchange into it from a known fragment, every exchange is read by exactly one fragment, the graph is acyclic, and its root (the one fragment whose output nobody reads) is an initiator fragment. Several fragments may have the initiator role, since a set fragment runs on the initiator too.computeLevelsreturns the topological levels for the renderers; they are not stored in the model.Building the graph
buildFragmentGraphwalks the stages and maps the executor's exchange and stage descriptions onto the model. For every receive step it walks towards the output of the fragment to the first step that needs all of its input on that way, keeping the input position at every parent.classifyDependencyis a pure function over that step: the build side of a join, a hash aggregation (not in order), a full sort and aMergingAggregatedthat does not merge bucket by bucket are blocking; when no such step exists the exchange streams. A materialised exchange and aSetValuesexchange are always blocking.makeDistributedPlannow copies the cost estimate of every original node onto the node it rebuilds, so the producer's estimate reaches the exchange.Tests
Unit tests for the pure algorithms on hand-built graphs, and for
buildFragmentGraphon hand-built cut plans (blocking consumers behindUnion, hash and in-order aggregation).Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/124600]
Version info
26.11.1.287-master(included in26.11and later)