Leonard Xu created FLINK-18548: ---------------------------------- Summary: Improve FlinkCalcMergeRule to merge calc nodes better Key: FLINK-18548 URL: https://issues.apache.org/jira/browse/FLINK-18548 Project: Flink Issue Type: Improvement Components: Table SQL / Planner Affects Versions: 1.12.0 Reporter: Leonard Xu
FlinkCalcMergeRule should merge calc nodes when outer calc do not contains inner calc's fields, the following logical plan can not merge as expected currently: {code:java} FlinkLogicalJoin(condition=[AND(=($0, $4), >($1, 1))], joinType=[left]) :- FlinkLogicalCalc(select=[id, len, content], where=[>(id, 1)]) : +- FlinkLogicalTableSourceScan(table=[[default_catalog, default_database, T]], fields=[id, len, content]) +- FlinkLogicalSnapshot(period=[$cor0.proctime]) +- FlinkLogicalCalc(select=[age, id, name], where=[AND(>(age, 20), =(name, _UTF-16LE'Fabian':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"))]) +- FlinkLogicalCalc(select=[age, id, name, PROCTIME() AS proctime]) +- FlinkLogicalTableSourceScan(table=[[default_catalog, default_database, userTable]], fields=[age, id, name]) {code} The corresponding SQL to reproduce this issue: {code:java} CREATE TABLE userTable ( `id` BIGINT, `len` BIGINT, `content` STRING, `proctime` AS PROCTIME() ) WITH ( 'connector' = 'values', 'data-id' = '$dataId', 'bounded' = 'true' ) SELECT T.id, T.len, T.content, D.name FROM T JOIN userTable " + "for system_time as of T.proctime AS D ON T.id = D.id {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)