[FLINK-36472][table] Preserve right-side projections when converting Correlate to physical#28246
Open
Au-Miner wants to merge 1 commit into
Open
[FLINK-36472][table] Preserve right-side projections when converting Correlate to physical#28246Au-Miner wants to merge 1 commit into
Au-Miner wants to merge 1 commit into
Conversation
…Correlate to physical
Collaborator
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.
What is the purpose of the change
When a
Correlatehas aCalcon its right side that adds non-identity projections (e.g.LATERAL (SELECT s * 2 FROM UNNEST(...) AS T(s))), the physical conversion previously dropped those projections, leaving wrong output columns. This PR preserves them by wrapping the resultingCorrelatein aCalcthat re-applies the right-side projections.Brief change log
StreamPhysicalCorrelateRule/BatchPhysicalCorrelateRule: split the right-side calc into(scan, projects, condition); when projects are non-identity, build an inner*PhysicalCorrelatewith the natural join row type and wrap it in a*PhysicalCalcwhose program is built by the newbuildOuterProgramhelper that shifts right-side projections past the left field count.FlinkCalcMergeRule: addBATCH_PHYSICAL_INSTANCEso the new wrapping calc can merge with adjacent batch calcs (mirrors the existingSTREAM_PHYSICAL_INSTANCE).FlinkBatchRuleSets#PHYSICAL_OPT_RULES: registerFlinkCalcMergeRule.BATCH_PHYSICAL_INSTANCE.Verifying this change
Added
testLateralProjectionFromUnnestinUnnestTestBase(exercised by both stream and batchUnnestTest) which asserts that the optimized plan contains aCalc(select=[a, *(b0, 2) AS doubled])over theCorrelate. AddedtestCorrelateWithRightSideProjectioninCorrelateITCasewhich runsLATERAL (SELECT CONCAT(v, '_x') FROM TABLE(STRING_SPLIT(c, '|')) AS T(v))and asserts the projected values appear in the sink. UpdatedUnnestTest.xmlplans (stream + batch) accordingly.Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation