Merge pull request #12456 from CurtizJ/fix-12437

Fix #12437
This commit is contained in:
alexey-milovidov 2020-07-14 09:28:31 +03:00 committed by GitHub
commit fd4adf27d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 1 deletions

View File

@ -74,8 +74,9 @@ size_t MergeTreeReaderInMemory::readRows(size_t from_mark, bool continue_reading
auto mutable_column = res_columns[i]->assumeMutable();
auto & res_offstes = assert_cast<ColumnArray &>(*mutable_column).getOffsets();
size_t start_offset = total_rows_read ? source_offsets[total_rows_read - 1] : 0;
for (size_t row = 0; row < rows_to_read; ++row)
res_offstes.push_back(source_offsets[total_rows_read + row]);
res_offstes.push_back(source_offsets[total_rows_read + row] - start_offset);
res_columns[i] = std::move(mutable_column);
}

View File

@ -0,0 +1,25 @@
[0]
[0,0,0]
[0,0,0,0,0]
[0,0,0,0,0,0,0]
[0,0,0,0,0,0,0,0,0]
[0]
[0,0,0]
[0,0,0,0,0]
[0,0,0,0,0,0,0]
[0,0,0,0,0,0,0,0,0]
[0]
[0,0,0]
[0,0,0,0,0]
[0,0,0,0,0,0,0]
[0,0,0,0,0,0,0,0,0]
[0]
[0,2,4]
[0,2,4,6,8]
[0,2,4,6,8,10,12]
[0,2,4,6,8,10,12,14,16]
[0] [0]
[0,1,2] [0,2,4]
[0,1,2,3,4] [0,2,4,6,8]
[0,1,2,3,4,5,6] [0,2,4,6,8,10,12]
[0,1,2,3,4,5,6,7,8] [0,2,4,6,8,10,12,14,16]

View File

@ -0,0 +1,18 @@
-- Test 00576_nested_and_prewhere, but with in-memory parts.
DROP TABLE IF EXISTS nested;
CREATE TABLE nested (x UInt64, filter UInt8, n Nested(a UInt64)) ENGINE = MergeTree ORDER BY x
SETTINGS min_rows_for_compact_part = 200000, min_rows_for_wide_part = 300000;
INSERT INTO nested SELECT number, number % 2, range(number % 10) FROM system.numbers LIMIT 100000;
ALTER TABLE nested ADD COLUMN n.b Array(UInt64);
SELECT DISTINCT n.b FROM nested PREWHERE filter;
SELECT DISTINCT n.b FROM nested PREWHERE filter SETTINGS max_block_size = 10;
SELECT DISTINCT n.b FROM nested PREWHERE filter SETTINGS max_block_size = 123;
ALTER TABLE nested ADD COLUMN n.c Array(UInt64) DEFAULT arrayMap(x -> x * 2, n.a);
SELECT DISTINCT n.c FROM nested PREWHERE filter;
SELECT DISTINCT n.a, n.c FROM nested PREWHERE filter;
DROP TABLE nested;