From e6a41a0256f7187a268537f8384a3b4dbdf4efc4 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 24 Mar 2017 07:42:36 +0300 Subject: [PATCH] Fixed error with NULLs [#CLICKHOUSE-2901]. --- dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp | 2 +- .../queries/0_stateless/00440_nulls_merge_tree.reference | 1 + dbms/tests/queries/0_stateless/00440_nulls_merge_tree.sql | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 dbms/tests/queries/0_stateless/00440_nulls_merge_tree.reference create mode 100644 dbms/tests/queries/0_stateless/00440_nulls_merge_tree.sql diff --git a/dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp b/dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp index 248fdef0aa5..d755aafd55f 100644 --- a/dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp +++ b/dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp @@ -171,7 +171,7 @@ void IMergedBlockOutputStream::writeDataImpl( writeIntBinary(stream.compressed.offset(), stream.marks); } - DataTypeUInt8{}.serializeBinaryBulk(nullable_col.getNullMapConcreteColumn(), stream.compressed, 0, 0); + DataTypeUInt8{}.serializeBinaryBulk(nullable_col.getNullMapConcreteColumn(), stream.compressed, prev_mark, limit); /// This way that instead of the marks pointing to the end of the compressed block, there were marks pointing to the beginning of the next one. stream.compressed.nextIfAtEnd(); diff --git a/dbms/tests/queries/0_stateless/00440_nulls_merge_tree.reference b/dbms/tests/queries/0_stateless/00440_nulls_merge_tree.reference new file mode 100644 index 00000000000..83b33d238da --- /dev/null +++ b/dbms/tests/queries/0_stateless/00440_nulls_merge_tree.reference @@ -0,0 +1 @@ +1000 diff --git a/dbms/tests/queries/0_stateless/00440_nulls_merge_tree.sql b/dbms/tests/queries/0_stateless/00440_nulls_merge_tree.sql new file mode 100644 index 00000000000..b3386d5444e --- /dev/null +++ b/dbms/tests/queries/0_stateless/00440_nulls_merge_tree.sql @@ -0,0 +1,5 @@ +DROP TABLE IF EXISTS test.nulls; +CREATE TABLE test.nulls (d Date, x Nullable(UInt64)) ENGINE = MergeTree(d, d, 8192); +INSERT INTO test.nulls SELECT toDate('2000-01-01'), number % 10 != 0 ? number : NULL FROM system.numbers LIMIT 10000; +SELECT count() FROM test.nulls WHERE x IS NULL; +DROP TABLE test.nulls;