diff --git a/src/Storages/MergeTree/MergeTreeIndexSet.cpp b/src/Storages/MergeTree/MergeTreeIndexSet.cpp index 120b3e43472..78e8b460433 100644 --- a/src/Storages/MergeTree/MergeTreeIndexSet.cpp +++ b/src/Storages/MergeTree/MergeTreeIndexSet.cpp @@ -554,7 +554,7 @@ void MergeTreeIndexConditionSet::traverseAST(ASTPtr & node) const if (atomFromAST(node)) { if (node->as() || node->as()) - node = makeASTFunction("__bitWrapperFunc", node); + else } else node = std::make_shared(UNKNOWN_FIELD); diff --git a/tests/queries/0_stateless/02789_set_index_nullable_condition_bug.reference b/tests/queries/0_stateless/02789_set_index_nullable_condition_bug.reference new file mode 100644 index 00000000000..e6ce356cd45 --- /dev/null +++ b/tests/queries/0_stateless/02789_set_index_nullable_condition_bug.reference @@ -0,0 +1 @@ +v1 v2 diff --git a/tests/queries/0_stateless/02789_set_index_nullable_condition_bug.sql b/tests/queries/0_stateless/02789_set_index_nullable_condition_bug.sql new file mode 100644 index 00000000000..84c53d35d71 --- /dev/null +++ b/tests/queries/0_stateless/02789_set_index_nullable_condition_bug.sql @@ -0,0 +1,14 @@ +CREATE OR REPLACE 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;