From ae2c50e9e8d76d4ec73845dbbcd0db1f9222a457 Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Sun, 16 Aug 2020 15:16:37 +0800 Subject: [PATCH] Fix set index with const column pred --- src/Storages/MergeTree/MergeTreeIndexSet.cpp | 3 ++- tests/queries/0_stateless/01450_set_null_const.reference | 1 + tests/queries/0_stateless/01450_set_null_const.sql | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/queries/0_stateless/01450_set_null_const.reference create mode 100644 tests/queries/0_stateless/01450_set_null_const.sql diff --git a/src/Storages/MergeTree/MergeTreeIndexSet.cpp b/src/Storages/MergeTree/MergeTreeIndexSet.cpp index 3d0c0327da5..9aaf894a0cb 100644 --- a/src/Storages/MergeTree/MergeTreeIndexSet.cpp +++ b/src/Storages/MergeTree/MergeTreeIndexSet.cpp @@ -291,7 +291,8 @@ bool MergeTreeIndexConditionSet::mayBeTrueOnGranule(MergeTreeIndexGranulePtr idx Block result = granule->block; actions->execute(result); - auto column = result.getByName(expression_ast->getColumnName()).column->convertToFullColumnIfLowCardinality(); + auto column + = result.getByName(expression_ast->getColumnName()).column->convertToFullColumnIfConst()->convertToFullColumnIfLowCardinality(); const auto * col_uint8 = typeid_cast(column.get()); const NullMap * null_map = nullptr; diff --git a/tests/queries/0_stateless/01450_set_null_const.reference b/tests/queries/0_stateless/01450_set_null_const.reference new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/tests/queries/0_stateless/01450_set_null_const.reference @@ -0,0 +1 @@ +0 diff --git a/tests/queries/0_stateless/01450_set_null_const.sql b/tests/queries/0_stateless/01450_set_null_const.sql new file mode 100644 index 00000000000..c47176a880f --- /dev/null +++ b/tests/queries/0_stateless/01450_set_null_const.sql @@ -0,0 +1,7 @@ +DROP TABLE IF EXISTS test_mtree; + +CREATE TABLE test_mtree (`x` String, INDEX idx x TYPE set(10) GRANULARITY 1) ENGINE = MergeTree ORDER BY tuple(); +INSERT INTO test_mtree VALUES ('Hello, world'); +SELECT count() FROM test_mtree WHERE x = NULL; + +DROP TABLE test_mtree;