WuZixing opened a new issue #4487:
URL: https://github.com/apache/incubator-doris/issues/4487


   **Describe the bug**
   The predicate in the following SQL should not be pushed down to the 
OlapScanNode corresponding to the left table.
   `SELECT * FROM t1 RIGHT ANTI JOIN t0 ON t1.c2 = t0.c2 AND t1.c4 = t0.c3 
WHERE true is NULL;`
   
   The result set of this query should be empty. The real execution pushes down 
the predicate in WHERE clause to the scan node under `t1`, and left table 
(`t1`) of the right-anti-join would be empty, so all rows from the right table 
(`t0`) are outputted after join as the result set. 
   
   **To Reproduce**
   Steps to reproduce the behavior:
   1. Create 2 tables:
   
   Schema:
   
   ```
   CREATE TABLE `t0` (
     `c0` tinyint NOT NULL,
     `c1` tinyint NOT NULL
   ) ENGINE=OLAP
   UNIQUE KEY(`c0`, `c1`)
   COMMENT "OLAP"
   DISTRIBUTED BY HASH(`c1`, `c0`) BUCKETS 10
   PROPERTIES (
   "replication_num" = "1",
   "in_memory" = "false",
   "storage_format" = "DEFAULT"
   );
   ```
   
   ```
   CREATE TABLE `t1` (
     `c0` tinyint NOT NULL,
     `c1` tinyint NOT NULL
   ) ENGINE=OLAP
   UNIQUE KEY(`c0`, `c1`)
   COMMENT "OLAP"
   DISTRIBUTED BY HASH(`c1`, `c0`) BUCKETS 10
   PROPERTIES (
   "replication_num" = "1",
   "in_memory" = "false",
   "storage_format" = "DEFAULT"
   );
   ```
   
   Rows:
   
   ```
   insert into t0 (c0,c1) values (1, 2);
   insert into t1 (c0,c1) values (3, 4);
   ```
   
   2. This query will produce a result set of one row `(1,2)`, while it's 
supposed to be empty:
   
   `SELECT * FROM t1 RIGHT ANTI JOIN t0 ON t1.c0 = t0.c0 AND t1.c1 = t0.c1 
WHERE true is NULL;`
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to