[ https://issues.apache.org/jira/browse/FLINK-29088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17597080#comment-17597080 ]
Aitozi commented on FLINK-29088: -------------------------------- After some research, here is some progress: When using the logical rule to detect the same source node, due to the calcite can only optimize the single root, so it can only reuse the source node in the same tree. The same source node in different {{RelRoot}} will be skipped. When trying to detect the same source after the physical optimize. It becomes much complicated because there also need to deal with the output type of the source table (which may be also affects the PushDownWaterMark and so on) So I lean to follow your suggestion to add a logical rule to optimize in the single tree first. I have pass the poc verify and will prepare a PR for it ASAP. > Project push down cause the source reuse can not work > ----------------------------------------------------- > > Key: FLINK-29088 > URL: https://issues.apache.org/jira/browse/FLINK-29088 > Project: Flink > Issue Type: Improvement > Components: Table SQL / Planner > Reporter: Aitozi > Assignee: Aitozi > Priority: Major > > It can be reproduce by > {code:java} > util.addTable( > s""" > |create table newX( > | a int, > | b bigint, > | c varchar > |) with ( > | 'connector' = 'values' > | ,'enable-projection-push-down' = 'true' > |) > """.stripMargin) > val sqlQuery = > """ > | SELECT b from newX WHERE a > 10 > | UNION ALL > | SELECT b from newX WHERE b > 10 > """.stripMargin > util.verifyExecPlan(sqlQuery) > {code} > if 'enable-projection-push-down' set to true, the source will not be reused. > If set to false, the source will be reused. -- This message was sent by Atlassian Jira (v8.20.10#820010)