Merge pull request #19884 from kitaisreal/bloom-filter-index-crash-fix

BloomFilter index crash fix
This commit is contained in:
alexey-milovidov 2021-02-01 15:42:56 +03:00 committed by GitHub
commit f09158de0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 71 additions and 1 deletions

View File

@ -140,7 +140,16 @@ void Set::setHeader(const Block & header)
ConstNullMapPtr null_map{};
ColumnPtr null_map_holder;
if (!transform_null_in)
{
/// We convert nullable columns to non nullable we also need to update nullable types
for (size_t i = 0; i < set_elements_types.size(); ++i)
{
data_types[i] = removeNullable(data_types[i]);
set_elements_types[i] = removeNullable(set_elements_types[i]);
}
extractNestedColumnsAndNullMap(key_columns, null_map);
}
if (fill_set_elements)
{
@ -182,7 +191,7 @@ bool Set::insertFromBlock(const Block & block)
ConstNullMapPtr null_map{};
ColumnPtr null_map_holder;
if (!transform_null_in)
null_map_holder = extractNestedColumnsAndNullMap(key_columns, null_map);
null_map_holder = extractNestedColumnsAndNullMap(key_columns, null_map);
/// Filter to extract distinct values from the block.
ColumnUInt8::MutablePtr filter;

View File

@ -0,0 +1,10 @@
NullableTuple with transform_null_in=0
NullableTuple with transform_null_in=1
NullableColumnFromCast with transform_null_in=0
1 test
NullableColumnFromCast with transform_null_in=1
1 test
NullableColumnFromTable with transform_null_in=0
1 test
NullableColumnFromTable with transform_null_in=1
1 test

View File

@ -0,0 +1,51 @@
DROP TABLE IF EXISTS bloom_filter_nullable_index;
CREATE TABLE bloom_filter_nullable_index
(
order_key UInt64,
str Nullable(String),
INDEX idx (str) TYPE bloom_filter GRANULARITY 1
)
ENGINE = MergeTree()
ORDER BY order_key SETTINGS index_granularity = 6;
INSERT INTO bloom_filter_nullable_index VALUES (1, 'test');
INSERT INTO bloom_filter_nullable_index VALUES (2, 'test2');
SELECT 'NullableTuple with transform_null_in=0';
SELECT * FROM bloom_filter_nullable_index WHERE str IN
(SELECT '1048576', str FROM bloom_filter_nullable_index) SETTINGS transform_null_in = 0;
SELECT * FROM bloom_filter_nullable_index WHERE str IN
(SELECT '1048576', str FROM bloom_filter_nullable_index) SETTINGS transform_null_in = 0;
SELECT 'NullableTuple with transform_null_in=1';
SELECT * FROM bloom_filter_nullable_index WHERE str IN
(SELECT '1048576', str FROM bloom_filter_nullable_index) SETTINGS transform_null_in = 1; -- { serverError 20 }
SELECT * FROM bloom_filter_nullable_index WHERE str IN
(SELECT '1048576', str FROM bloom_filter_nullable_index) SETTINGS transform_null_in = 1; -- { serverError 20 }
SELECT 'NullableColumnFromCast with transform_null_in=0';
SELECT * FROM bloom_filter_nullable_index WHERE str IN
(SELECT cast('test', 'Nullable(String)')) SETTINGS transform_null_in = 0;
SELECT 'NullableColumnFromCast with transform_null_in=1';
SELECT * FROM bloom_filter_nullable_index WHERE str IN
(SELECT cast('test', 'Nullable(String)')) SETTINGS transform_null_in = 1;
DROP TABLE IF EXISTS nullable_string_value;
CREATE TABLE nullable_string_value (value Nullable(String)) ENGINE=TinyLog;
INSERT INTO nullable_string_value VALUES ('test');
SELECT 'NullableColumnFromTable with transform_null_in=0';
SELECT * FROM bloom_filter_nullable_index WHERE str IN
(SELECT value FROM nullable_string_value) SETTINGS transform_null_in = 0;
SELECT 'NullableColumnFromTable with transform_null_in=1';
SELECT * FROM bloom_filter_nullable_index WHERE str IN
(SELECT value FROM nullable_string_value) SETTINGS transform_null_in = 1;
DROP TABLE nullable_string_value;
DROP TABLE bloom_filter_nullable_index;