Conversation
…xSubQuery expressions or Correlate
|
mihaibudiu
approved these changes
Sep 28, 2026
| assertNull(tableReferences); | ||
| } | ||
|
|
||
| @Test void testTableReferencesValues() { |
Contributor
There was a problem hiding this comment.
these tests are not easy for a human to review, I hope they are right
mihaibudiu
self-requested a review
September 28, 2026 18:20
mihaibudiu
reviewed
Sep 28, 2026
| * Table references from TableFunctionScan. | ||
| * | ||
| * <p>Returns an empty set if there are no inputs, and {@code null} if the table | ||
| * references of any input cannot be determined. Tables accessed internally |
Contributor
There was a problem hiding this comment.
why delete this comment?
|
|
||
| /** Table references from Snapshot. */ | ||
| public @Nullable Set<RelTableRef> getTableReferences(Snapshot rel, RelMetadataQuery mq) { | ||
| return mq.getTableReferences(rel.getInput()); |
Contributor
There was a problem hiding this comment.
don't you need to analyze the period operand to?
|
|
||
| /** Table references from Match. */ | ||
| public @Nullable Set<RelTableRef> getTableReferences(Match rel, RelMetadataQuery mq) { | ||
| return mq.getTableReferences(rel.getInput()); |
Contributor
There was a problem hiding this comment.
don't you need to analyze the pattern and measures operands?
| } | ||
|
|
||
| /** Table references from Spool. */ | ||
| public @Nullable Set<RelTableRef> getTableReferences(Spool rel, RelMetadataQuery mq) { |
Contributor
There was a problem hiding this comment.
apparently there are still some classes not handled, like Window, Sort, TableModify
| List<RelNode> inputs, RelMetadataQuery mq) { | ||
| List<RelNode> inputs, List<? extends RexNode> expressions, RelMetadataQuery mq) { | ||
| final List<RelNode> rels = new ArrayList<>(inputs); | ||
| final RexVisitorImpl<Void> visitor = new RexVisitorImpl<Void>(true) { |
Contributor
There was a problem hiding this comment.
you can reuse the SubQueryCollector visitor
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-7825
This is the follow-up to the #5288. @zzwqqq @vlsi Could you please review these changes?
RelMdTableReferences misses tables in RexSubQuery expressions in Project, Filter, Join, and Calc. It also has no Correlate handler, so rewriting a sub-query can change the result to null.
Other nodes also return null despite having determinable table references: Values should return an empty set, unary nodes should pass through their input references, and RepeatUnion and Combine should merge theirs.
Changes Proposed
Extend RelMdTableReferences to cover sub-queries, Correlate, and other nodes that previously returned null despite having determinable table references. Refactor Join to use the shared references extractor.