misc: Fix RemoveCrossJoinWithConstantInput to use unknown locality#27116
Merged
feilong-liu merged 1 commit intoprestodb:masterfrom Feb 10, 2026
Merged
misc: Fix RemoveCrossJoinWithConstantInput to use unknown locality#27116feilong-liu merged 1 commit intoprestodb:masterfrom
feilong-liu merged 1 commit intoprestodb:masterfrom
Conversation
Contributor
Reviewer's GuideAdjusts RemoveCrossJoinWithConstantInput so that the ProjectNode it introduces uses UNKNOWN locality instead of LOCAL, by extending PlannerUtils.addProjections to accept a locality parameter and adding unit tests to verify the new behavior with and without a join filter. Sequence diagram for RemoveCrossJoinWithConstantInput using UNKNOWN localitysequenceDiagram
participant RuleEngine
participant RemoveCrossJoinWithConstantInput
participant PlannerUtils
participant ProjectNode
participant PlanRemoteProjections
RuleEngine->>RemoveCrossJoinWithConstantInput: apply(joinNode, ruleContext)
RemoveCrossJoinWithConstantInput->>PlannerUtils: addProjections(joinInput, idAllocator, mapping, UNKNOWN)
PlannerUtils->>PlannerUtils: build Assignments from joinInput outputs
PlannerUtils->>ProjectNode: construct(id, joinInput, assignments, UNKNOWN)
ProjectNode-->>PlannerUtils: ProjectNode
PlannerUtils-->>RemoveCrossJoinWithConstantInput: ProjectNode with locality UNKNOWN
RemoveCrossJoinWithConstantInput-->>RuleEngine: Result with rewritten plan
RuleEngine->>PlanRemoteProjections: apply(planWithProjectNode, ruleContext)
PlanRemoteProjections->>ProjectNode: inspect locality (UNKNOWN)
PlanRemoteProjections->>ProjectNode: set locality based on distribution (LOCAL or REMOTE)
ProjectNode-->>PlanRemoteProjections: ProjectNode with final locality
PlanRemoteProjections-->>RuleEngine: updated plan with planned remote projections
Class diagram for updated PlannerUtils and RemoveCrossJoinWithConstantInputclassDiagram
class PlannerUtils {
+addProjections(source: PlanNode, planNodeIdAllocator: PlanNodeIdAllocator, variableMap: Map~VariableReferenceExpression, RowExpression~): PlanNode
+addProjections(source: PlanNode, planNodeIdAllocator: PlanNodeIdAllocator, variableMap: Map~VariableReferenceExpression, RowExpression~, locality: Locality): PlanNode
}
class RemoveCrossJoinWithConstantInput {
+apply(node: JoinNode, context: RuleContext): Result
}
class ProjectNode {
+ProjectNode(id: PlanNodeId, source: PlanNode, assignments: Assignments, locality: Locality)
+getId(): PlanNodeId
+getSource(): PlanNode
+getAssignments(): Assignments
+getLocality(): Locality
}
class Locality {
<<enumeration>>
LOCAL
UNKNOWN
REMOTE
}
PlannerUtils ..> ProjectNode : creates
PlannerUtils ..> Locality : uses
RemoveCrossJoinWithConstantInput ..> PlannerUtils : uses
RemoveCrossJoinWithConstantInput ..> Locality : uses
ProjectNode --> Locality
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1263811 to
b925f41
Compare
kaikalur
approved these changes
Feb 10, 2026
NikhilCollooru
approved these changes
Feb 10, 2026
This was referenced Mar 31, 2026
15 tasks
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.
Description
Locality of a project is set in
PlanRemoteProjectionsoptimizer.RemoveCrossJoinWithConstantInputruns before PlanRemoteProjection, and we should not set the project locality to local, it should be unknown and wait forPlanRemoteProjectionsto set it.Motivation and Context
As in description
Impact
Bug fix
Test Plan
Unit tests
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.
Summary by Sourcery
Ensure projections created when removing cross joins with constant inputs default to unknown locality so later optimizers can determine appropriate locality.
Bug Fixes:
Enhancements:
Tests: