Query graph for Join reordering#22050
Open
JanKaul wants to merge 7 commits intoapache:mainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
Join-ordering algorithms (DPhyp, DPccp, …) operate on a graph view of the join region rather than a
LogicalPlantree. DataFusion has no such structure today, so any future reordering rule has to re-derive one. This PR adds the data structure and theLogicalPlan ⇄ JoinGraphboundary so the follow-up enumeration work in epic #18249 has something concrete to build on.What changes are included in this PR?
New
datafusion/optimizer/src/reorder_join/join_graph.rs:JoinGraph,Node,EdgewithNodeId/EdgeIdhandles backed by an internalVecMap(stable indices, no reuse on removal).JoinGraph::try_from_logical_plan(plan) -> Result<(JoinGraph, Vec<LogicalPlan>)>:Join.filterandFilternodes sitting between inner joins — into a side-channelfilterslist;reconstruct_plan(join_plan, wrappers)re-applies the stripped wrappers after reordering.add_node,add_node_with_edge,remove_node,remove_edge,Node::neighbours,Node::connections.datafusion/optimizer/src/lib.rs.No optimizer rule is registered; nothing consumes
JoinGraphoutside tests.Are these changes tested?
Yes — unit tests in
join_graph.rs:Join.filter(predicate lands in side-channel);Filterbetween two inner joins (hoisted; both joins still decompose);Aggregatebetween two inner joins (opaque leaf);LEFTjoin nested inside an inner chain (opaque leaf);No sqllogictest changes — no planner-visible behavior yet.
Are there any user-facing changes?
No.
JoinGraphis a new internal data structure indatafusion-optimizer; no existing API changes and no rule consumes it yet.