fix error for in Null

This commit is contained in:
liuneng 2024-03-20 12:29:48 +08:00
parent 862abf2f6e
commit 45bbef689a
3 changed files with 14 additions and 3 deletions

View File

@ -32,9 +32,12 @@ public:
auto * constant_node = args[1]->as<ConstantNode>();
if (!column_node || !constant_node)
return ;
// IN multiple values is not supported
if (constant_node->getValue().getType() == Field::Types::Which::Tuple)
return;
return ;
// x IN null not equivalent to x = null
if (constant_node->hasSourceExpression() || constant_node->getValue().isNull())
return ;
auto equal_resolver = createInternalFunctionEqualOverloadResolver();
auto equal = std::make_shared<FunctionNode>("equals");
QueryTreeNodes arguments{column_node->clone(), constant_node->clone()};

View File

@ -1,5 +1,11 @@
a 1
-------------------
0
0
0
0
0
-------------------
QUERY id: 0
PROJECTION COLUMNS
x String

View File

@ -5,6 +5,8 @@ INSERT INTO test VALUES ('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5);
select * from test where x in ('a') SETTINGS allow_experimental_analyzer = 1;
select '-------------------';
select x in Null from test;
select '-------------------';
explain query tree select * from test where x in ('a') SETTINGS allow_experimental_analyzer = 1;
select '-------------------';
explain query tree select * from test where x in ('a','b') SETTINGS allow_experimental_analyzer = 1;
explain query tree select * from test where x in ('a','b') SETTINGS allow_experimental_analyzer = 1;