mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #51205 from ClickHouse/set-index-nullable-atoms
Fix Set index with constant nullable comparison.
This commit is contained in:
commit
b10bcbc7f4
@ -554,7 +554,10 @@ void MergeTreeIndexConditionSet::traverseAST(ASTPtr & node) const
|
||||
if (atomFromAST(node))
|
||||
{
|
||||
if (node->as<ASTIdentifier>() || node->as<ASTFunction>())
|
||||
node = makeASTFunction("__bitWrapperFunc", node);
|
||||
/// __bitWrapperFunc* uses default implementation for Nullable types
|
||||
/// Here we additionally convert Null to 0,
|
||||
/// otherwise condition 'something OR NULL' will always return Null and filter everything.
|
||||
node = makeASTFunction("__bitWrapperFunc", makeASTFunction("ifNull", node, std::make_shared<ASTLiteral>(Field(0))));
|
||||
}
|
||||
else
|
||||
node = std::make_shared<ASTLiteral>(UNKNOWN_FIELD);
|
||||
|
@ -0,0 +1 @@
|
||||
v1 v2
|
@ -0,0 +1,15 @@
|
||||
drop table if exists test_table;
|
||||
CREATE TABLE test_table
|
||||
(
|
||||
col1 String,
|
||||
col2 String,
|
||||
INDEX test_table_col2_idx col2 TYPE set(0) GRANULARITY 1
|
||||
) ENGINE = MergeTree()
|
||||
ORDER BY col1
|
||||
AS SELECT 'v1', 'v2';
|
||||
|
||||
SELECT * FROM test_table
|
||||
WHERE 1 == 1 AND col1 == col1 OR
|
||||
0 AND col2 == NULL;
|
||||
|
||||
drop table if exists test_table;
|
Loading…
Reference in New Issue
Block a user