BloomFilter index crash fix

This commit is contained in:
Maksim Kita 2021-01-31 21:49:27 +03:00
parent 342baa4223
commit 1aa8d7fdfb
3 changed files with 75 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,55 @@
CREATE DATABASE 01681_bloom_filter_nullable_column;
DROP TABLE IF EXISTS 01681_bloom_filter_nullable_column.bloom_filter_nullable_index;
CREATE TABLE 01681_bloom_filter_nullable_column.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 01681_bloom_filter_nullable_column.bloom_filter_nullable_index VALUES (1, 'test');
INSERT INTO 01681_bloom_filter_nullable_column.bloom_filter_nullable_index VALUES (2, 'test2');
SELECT 'NullableTuple with transform_null_in=0';
SELECT * FROM 01681_bloom_filter_nullable_column.bloom_filter_nullable_index WHERE str IN
(SELECT '1048576', str FROM 01681_bloom_filter_nullable_column.bloom_filter_nullable_index) SETTINGS transform_null_in = 0;
SELECT * FROM 01681_bloom_filter_nullable_column.bloom_filter_nullable_index WHERE str IN
(SELECT '1048576', str FROM 01681_bloom_filter_nullable_column.bloom_filter_nullable_index) SETTINGS transform_null_in = 0;
SELECT 'NullableTuple with transform_null_in=1';
SELECT * FROM 01681_bloom_filter_nullable_column.bloom_filter_nullable_index WHERE str IN
(SELECT '1048576', str FROM 01681_bloom_filter_nullable_column.bloom_filter_nullable_index) SETTINGS transform_null_in = 1; -- { serverError 20 }
SELECT * FROM 01681_bloom_filter_nullable_column.bloom_filter_nullable_index WHERE str IN
(SELECT '1048576', str FROM 01681_bloom_filter_nullable_column.bloom_filter_nullable_index) SETTINGS transform_null_in = 1; -- { serverError 20 }
SELECT 'NullableColumnFromCast with transform_null_in=0';
SELECT * FROM 01681_bloom_filter_nullable_column.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 01681_bloom_filter_nullable_column.bloom_filter_nullable_index WHERE str IN
(SELECT cast('test', 'Nullable(String)')) SETTINGS transform_null_in = 1;
CREATE TABLE 01681_bloom_filter_nullable_column.nullable_string_value (value Nullable(String)) ENGINE=TinyLog;
INSERT INTO 01681_bloom_filter_nullable_column.nullable_string_value VALUES ('test');
SELECT 'NullableColumnFromTable with transform_null_in=0';
SELECT * FROM 01681_bloom_filter_nullable_column.bloom_filter_nullable_index WHERE str IN
(SELECT value FROM 01681_bloom_filter_nullable_column.nullable_string_value) SETTINGS transform_null_in = 0;
SELECT 'NullableColumnFromTable with transform_null_in=1';
SELECT * FROM 01681_bloom_filter_nullable_column.bloom_filter_nullable_index WHERE str IN
(SELECT value FROM 01681_bloom_filter_nullable_column.nullable_string_value) SETTINGS transform_null_in = 1;
DROP TABLE 01681_bloom_filter_nullable_column.nullable_string_value;
DROP TABLE 01681_bloom_filter_nullable_column.bloom_filter_nullable_index;
DROP DATABASE 01681_bloom_filter_nullable_column;