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;