Skip to content

Decorrelate single-row values#15989

Merged
kasiafi merged 2 commits intotrinodb:masterfrom
kasiafi:450RemoveRedundantProjectAndWindow
Feb 7, 2023
Merged

Decorrelate single-row values#15989
kasiafi merged 2 commits intotrinodb:masterfrom
kasiafi:450RemoveRedundantProjectAndWindow

Conversation

@kasiafi
Copy link
Copy Markdown
Member

@kasiafi kasiafi commented Feb 6, 2023

Before this change, the rule TransformCorrelatedSingleRowSubqueryToProject matched a CorrelatedJoinNode with arbitrary number of ProjectNodes in the subquery. It supported identity projections and at most one non-identity projection.
After this change, the rule supports 0 or 1 projection. Projections can be inlined by the rule InlineProjections.

This change also extends the rule to handle more kinds of ValuesNode: after the change any single-row values is supported provided that the values row is an expression of type Row.

This change can be also considered a preparatory step before the rule MergeProjectWithValues is used more widely. It removes dependency between the MergeProjectWithValues rule and the de-correlating rules.

# General
* Support correlated queries involving single-row Values.

@cla-bot cla-bot bot added the cla-signed label Feb 6, 2023
@kasiafi kasiafi force-pushed the 450RemoveRedundantProjectAndWindow branch from 516c0a1 to d262a73 Compare February 6, 2023 19:22
@kasiafi kasiafi changed the title Simplify decorrelation rule for scalar subquery Decorrelate single-row values Feb 6, 2023
Before this change, the rule TransformCorrelatedSingleRowSubqueryToProject
matched a CorrelatedJoinNode with arbitrary number of ProjectNodes
in the subquery. It supported identity projections and at most one
non-identity projection.
After this change, the rule supports 0 or 1 projection. Projections can be
inlined by the rule InlineProjections.
@kasiafi kasiafi force-pushed the 450RemoveRedundantProjectAndWindow branch from d262a73 to bc1ce8d Compare February 7, 2023 08:25
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should you reflect changes in class javadoc?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The javadoc was still valid. I added another example with subquery containing no projection.

Copy link
Copy Markdown
Member

@losipiuk losipiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This change extends rule TransformCorrelatedSingleRowSubqueryToProject
so that it supports subqueries being single-row values producing
output symbols.
@kasiafi kasiafi force-pushed the 450RemoveRedundantProjectAndWindow branch from bc1ce8d to f221608 Compare February 7, 2023 08:50
@kasiafi kasiafi merged commit 1e0b7c4 into trinodb:master Feb 7, 2023
@github-actions github-actions bot added this to the 407 milestone Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants