Skip to content

Commit

Permalink
[fix](planner)correlated predicate should include isnull predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
starocean999 committed May 14, 2024
1 parent 17b1df5 commit e0b1ba4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,8 @@ private static boolean containsCorrelatedPredicate(Expr root, List<TupleId> tupl
* query block (i.e. is not bound by the given 'tupleIds').
*/
private static boolean isCorrelatedPredicate(Expr expr, List<TupleId> tupleIds) {
return (expr instanceof BinaryPredicate || expr instanceof SlotRef) && !expr.isBoundByTupleIds(tupleIds);
return (expr instanceof BinaryPredicate || expr instanceof SlotRef
|| expr instanceof IsNullPredicate) && !expr.isBoundByTupleIds(tupleIds);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,45 @@ suite("test_subquery_with_agg") {
drop table if exists agg_subquery_table;
"""

sql """drop table if exists subquery_table_xyz;"""
sql """CREATE TABLE `subquery_table_xyz` (
`phone`bigint(20) NULL
) ENGINE=OLAP
DUPLICATE KEY(`phone`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`phone`) BUCKETS 3
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);"""
sql """WITH tmp1 AS
(SELECT DISTINCT phone
FROM subquery_table_xyz oua
WHERE (NOT EXISTS
(SELECT 1
FROM subquery_table_xyz o1
WHERE oua.phone = o1.phone
AND phone IS NOT NULL))),
tmp2 AS
(SELECT DISTINCT phone
FROM subquery_table_xyz oua
WHERE (NOT EXISTS
(SELECT 1
FROM subquery_table_xyz o1
WHERE oua.phone = o1.phone
and phone IS NOT NULL))),
tmp3 AS
(SELECT DISTINCT phone
FROM subquery_table_xyz oua
WHERE (NOT EXISTS
(SELECT 1
FROM subquery_table_xyz o1
WHERE oua.phone = o1.phone and
phone IS NOT NULL)))
SELECT COUNT(DISTINCT tmp1.phone)
FROM tmp1
JOIN tmp2
ON tmp1.phone = tmp2.phone
JOIN tmp3
ON tmp2.phone = tmp3.phone;"""

}

0 comments on commit e0b1ba4

Please sign in to comment.