You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Jing Zhang (Jira)" <ji...@apache.org> on 2022/01/11 07:26:00 UTC

[jira] [Updated] (FLINK-25593) A redundant scan could be skipped if it is an input of join and the other input is empty after partition prune

     [ https://issues.apache.org/jira/browse/FLINK-25593?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jing Zhang updated FLINK-25593:
-------------------------------
    Description: 
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:sql}
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.


  was:
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.



> 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
>            Priority: Major
>
> 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:sql}
> 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)