-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-35804][table-planner] Fix incorrect calc merge during decorrelate phase #25068
[FLINK-35804][table-planner] Fix incorrect calc merge during decorrelate phase #25068
Conversation
@lincoln-lil @godfreyhe Would you mind reviewing this pr? Thanks~ |
@flinkbot Could someone review this pr? Thanks~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhaorongsheng Thanks for fixing this! The commit msg can be "Fix incorrect calc merge during decorrelate phase" since it happens in RelDecorrelator
.
@@ -207,4 +210,19 @@ class CalcTest extends TableTestBase { | |||
val sqlQuery = "SELECT a FROM (SELECT a, b FROM MyTable) t WHERE random_udf(b) > 10" | |||
util.verifyRelPlan(sqlQuery) | |||
} | |||
|
|||
@Test | |||
def testCalcMergeWithNonDeterministicExpr3(): Unit = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use a minimal case to reproduce the error, e.g.,
@Test
def testCalcMergeWithCorrelate(): Unit = {
util.addTemporarySystemFunction("str_split", new StringSplit())
val sqlQuery =
"""
|
|SELECT a, r FROM (
| SELECT a, random_udf(b) r FROM (
| select a, b, c1 FROM MyTable, LATERAL TABLE(str_split(c)) AS T(c1)
| ) t
|)
|WHERE r > 10
|""".stripMargin
util.verifyRelPlan(sqlQuery)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. The code and commit msg has been updated. Could you please check it again? Thanks~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhaorongsheng Thanks for the updating! Just one minor comment before merging.
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
Show resolved
Hide resolved
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
Outdated
Show resolved
Hide resolved
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
Outdated
Show resolved
Hide resolved
@zhaorongsheng Could you also cherry pick this patch into release-1.20 branch? |
…ate phase This closes apache#25068
I've created the backport pr #25084 to catch up 1.20's rc1 building. |
OK! |
…ate phase This closes apache#25068
What is the purpose of the change
Like the same issue in FLINK-30841.
Take one test as example:
optimized plan will be wrong:
the expected plan is:
Brief change log
change rule related to this problem in
RelDecorrelator
Verifying this change
Add new plan test in CalcTest
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation