Skip to content

Commit

Permalink
Add additional tests for queries with toLowCardinality and toNullable
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-hildred committed Apr 11, 2024
1 parent 70438f7 commit 13774d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Analyzer/Passes/LogicalExpressionOptimizerPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ class LogicalExpressionOptimizerVisitor : public InDepthQueryTreeVisitorWithCont
if (!child_function || !isBooleanFunction(child_function->getFunctionName()))
return;

if (function_node.getResultType()->isNullable() && !child_function->getResultType()->isNullable())
if (removeLowCardinality(constant->getResultType())->isNullable())
need_rerun_resolve = true;

if (maybe_invert)
Expand Down
4 changes: 4 additions & 0 deletions tests/queries/0_stateless/03032_redundant_equals.reference
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
100
100
101
100
101
100
101
1
1
1
Expand Down
3 changes: 2 additions & 1 deletion tests/queries/0_stateless/03032_redundant_equals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ SELECT * FROM test_table WHERE (NOT ((k in (101) = 0) OR (k in (100) = 1))) = 1;
SELECT * FROM test_table WHERE ((k not in (101) = 0) OR (k in (100) = 1)) = 1;
SELECT * FROM test_table WHERE ((k not in (99) = 1) AND (k in (100) = 1)) = 1;
SELECT * FROM test_table WHERE ((k not in (101) = toNullable(0)) OR (k in (100) = toNullable(1))) = toNullable(1);

SELECT * FROM test_table WHERE (((k NOT IN toLowCardinality(toNullable(101))) = toLowCardinality(toNullable(0))) OR ((k IN (toLowCardinality(100))) = toNullable(1)));
SELECT * FROM test_table WHERE (((k IN toLowCardinality(toNullable(101))) = toLowCardinality(toNullable(0))) AND ((k NOT IN (toLowCardinality(100))) = toNullable(1))) = toNullable(toLowCardinality(0));

SELECT count()
FROM
Expand Down

0 comments on commit 13774d8

Please sign in to comment.