Jing Zhang created FLINK-25593: ---------------------------------- Summary: A redundant scan could be skipped if it is an input of join and the other input is empty after partition prune Key: FLINK-25593 URL: https://issues.apache.org/jira/browse/FLINK-25593 Project: Flink Issue Type: Sub-task Components: Table SQL / Planner Reporter: Jing Zhang
A redundant scan could be skipped if it is an input of join and the other input is empty after partition prune. For example: ltable has two partitions: pt=0 ad pt=1, rtable has one partition pt1=0. The schema of ltable is (lkey string, value int). The schema of rtable is (rkey string, value int). {code:java} SELECT * FROM ltable, rtable WHERE pt=2 and pt1=0 and `lkey`=rkey {code} The plan is as following. {code:java} Calc(select=[lkey, value, CAST(2 AS INTEGER) AS pt, rkey, value1, CAST(0 AS INTEGER) AS pt1]) +- HashJoin(joinType=[InnerJoin], where=[=(lkey, rkey)], select=[lkey, value, rkey, value1], build=[right]) :- Exchange(distribution=[hash[lkey]]) : +- TableSourceScan(table=[[hive, source_db, ltable, partitions=[], project=[lkey, value]]], fields=[lkey, value]) +- Exchange(distribution=[hash[rkey]]) +- TableSourceScan(table=[[hive, source_db, rtable, partitions=[{pt1=0}], project=[rkey, value1]]], fields=[rkey, value1]) {code} There is no need to scan right side because the left input of join has 0 partitions after partition prune. -- This message was sent by Atlassian Jira (v8.20.1#820001)