Repository navigation
[CALCITE-7902] Planning fails with "is a PhysicalNode, which is not allowed in JoinAssociateRule" when calcite.enable.join.commute=true - #5372
Open
minogin wants to merge 1 commit into
Conversation
…llowed in JoinAssociateRule" when calcite.enable.join.commute=true Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
mihaibudiu
reviewed
Nov 13, 2026
mihaibudiu
left a comment
Contributor
There was a problem hiding this comment.
This may be fine, but the issue gives an example of a failing program.
Can you have a test with showing that the program now works?
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.



Jira: https://issues.apache.org/jira/browse/CALCITE-7902
Cause
VolcanoPlannerdoes not register transformation rules forPhysicalNodeclasses, so a physical rel never becomes the entry point of aTransformationRule. A rule call can still reach a physical rel while it matches the other operands. InVolcanoRuleCall.matchRecurse, the only check for transformation rules is that a rel has the same convention as the previously matched one.JoinAssociateRulehas operandsJoin(Join, RelNode). TheRelNodeoperand matches anAbstractConverterwith ENUMERABLE convention, whichExpandConversionRulecreates.AbstractConverteris not aPhysicalNode, so it is an entry point. From there the match goes up to the parentEnumerableHashJoinand down to its inputEnumerableHashJoin. All three have the ENUMERABLE convention, so the check passes, the rule fires on physical joins, andtransformTothrows... is a PhysicalNode, which is not allowed in JoinAssociateRule.Fix
In
matchRecurse, aTransformationRulenow skips a rel that is aPhysicalNode, as well as one whose convention differs. This matches whatVolcanoPlanner.addRuleandonNewClassalready do for entry points.Test
PlannerTest#testJoinAssociateDoesNotMatchPhysicalJoinruns a three-table join through Volcano withJOIN_ASSOCIATE,ExpandConversionRuleand the enumerable rules, including merge join. Without the fix it fails with the error from the issue.VolcanoPlannerTest,PlannerTest,RelOptRulesTest,org.apache.calcite.plan.*andTopDownOptTestpass.🤖 Generated with Claude Code