[CALCITE-7734] MATCH_RECOGNIZE with an unqualified column in MEASURES/DEFINE produces an unusable plan - #5210
Open
snuyanzin wants to merge 2 commits into
Open
[CALCITE-7734] MATCH_RECOGNIZE with an unqualified column in MEASURES/DEFINE produces an unusable plan#5210snuyanzin wants to merge 2 commits into
MATCH_RECOGNIZE with an unqualified column in MEASURES/DEFINE produces an unusable plan#5210snuyanzin wants to merge 2 commits into
Conversation
…RES`/`DEFINE` produces an unusable plan
xuzifu666
approved these changes
Aug 24, 2026
zzwqqq
reviewed
Aug 27, 2026
| pv = identifier.names.get(0); | ||
| // A qualifier that is not a declared pattern variable denotes the universal variable "*". | ||
| if (bb.scope instanceof MatchRecognizeScope | ||
| && !((MatchRecognizeScope) bb.scope).getPatternVars().contains(pv)) { |
Member
There was a problem hiding this comment.
Would this be handled correctly if the input table alias has the same name as a pattern variable? For example:
FROM a_source AS A
MATCH_RECOGNIZE (
MEASURES commission AS c
PATTERN (A B)
DEFINE
A AS A.empid >= 0,
B AS B.empid < 0
)
Here, A is both the input table alias and a pattern variable. I am not sure whether Calcite considers this case valid.
Contributor
Author
There was a problem hiding this comment.
yeah, you are right, good catch
updated PR and added a couple of more tests around this
|
zzwqqq
approved these changes
Aug 28, 2026
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 Link
CALCITE-7734
Changes Proposed
The PR fixes plan for
MATCH_RECOGNIZEwith an unqualified column inMEASURES/DEFINEbroken while CALCITE-7480