fix reading of subcolumns from compact parts

This commit is contained in:
Anton Popov 2021-09-10 20:19:18 +03:00
parent 43102e8427
commit a63887413c
3 changed files with 29 additions and 1 deletions

View File

@ -219,7 +219,13 @@ void MergeTreeReaderCompact::readData(
auto serialization = type_in_storage->getDefaultSerialization(); auto serialization = type_in_storage->getDefaultSerialization();
serialization->deserializeBinaryBulkStatePrefix(deserialize_settings, state); serialization->deserializeBinaryBulkStatePrefix(deserialize_settings, state);
serialization->deserializeBinaryBulkWithMultipleStreams(temp_column, rows_to_read, deserialize_settings, state, nullptr); serialization->deserializeBinaryBulkWithMultipleStreams(temp_column, rows_to_read, deserialize_settings, state, nullptr);
column = type_in_storage->getSubcolumn(name_and_type.getSubcolumnName(), *temp_column);
auto subcolumn = type_in_storage->getSubcolumn(name_and_type.getSubcolumnName(), *temp_column);
if (column->empty())
column = subcolumn;
else
column->assumeMutable()->insertRangeFrom(*subcolumn, 0, subcolumn->size());
} }
else else
{ {

View File

@ -0,0 +1,8 @@
0
0
0
0
0
0
40000
219970

View File

@ -0,0 +1,14 @@
DROP TABLE IF EXISTS t_comp_subcolumns;
CREATE TABLE t_comp_subcolumns (id UInt32, n Nullable(String), arr Array(Array(UInt32)))
ENGINE = MergeTree ORDER BY id;
INSERT INTO t_comp_subcolumns SELECT number, 'a', [range(number % 11), range(number % 13)] FROM numbers(20000);
SELECT sum(n.null) FROM t_comp_subcolumns;
SELECT n.null FROM t_comp_subcolumns LIMIT 10000, 5;
SELECT sum(arr.size0) FROM t_comp_subcolumns;
SELECT sumArray(arr.size1) FROM t_comp_subcolumns;
DROP TABLE t_comp_subcolumns;