Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.16.1
Description
currently we have a `FlinkCalcMergeRuleTest`, take one test as example:
@Test
def testCalcMergeWithNonDeterministicExpr1(): Unit = {
val sqlQuery = "SELECT a, a1 FROM (SELECT a, random_udf(a) AS a1 FROM MyTable) t WHERE a1 > 10"
util.verifyRelPlan(sqlQuery)
}
the current final optimized plan will be wrong:
Calc(select=[a, random_udf(b) AS a1], where=[(random_udf(b) > 10)]) +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c])
the merged calc contains two `random_udf` call, users may encounter the result satisfied by where predicate (>10) but the selected column <= 10, that's counter-intuitive for users
the expected plan is:
Calc(select=[a, a1], where=[(a1 > 10)]) +- Calc(select=[a, random_udf(b) AS a1]) +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c])
Attachments
Issue Links
- links to