incubator-doris [Bug] A predicate after right-anti-join should not be pushed down to the scan node of left table

rryofs0p  于 2022-04-22  发布在  Java
关注(0)|答案(1)|浏览(172)

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);
  1. 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;

相关问题