Skip to content

Commit

Permalink
Merge pull request #15871 from ClickHouse/backport/20.8/15662
Browse files Browse the repository at this point in the history
Backport #15662 to 20.8: Fix read from Buffer table with empty nested table with different types.
  • Loading branch information
KochetovNicolai committed Oct 15, 2020
2 parents 73abcb6 + 65126ba commit 2305111
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/Storages/StorageBuffer.cpp
Expand Up @@ -221,17 +221,20 @@ Pipe StorageBuffer::read(
columns_intersection, destination_metadata_snapshot, query_info,
context, processed_stage, max_block_size, num_streams);

pipe_from_dst.addSimpleTransform([&](const Block & stream_header)
if (!pipe_from_dst.empty())
{
return std::make_shared<AddingMissedTransform>(stream_header, header_after_adding_defaults,
metadata_snapshot->getColumns(), context);
});

pipe_from_dst.addSimpleTransform([&](const Block & stream_header)
{
return std::make_shared<ConvertingTransform>(
stream_header, header, ConvertingTransform::MatchColumnsMode::Name);
});
pipe_from_dst.addSimpleTransform([&](const Block & stream_header)
{
return std::make_shared<AddingMissedTransform>(stream_header, header_after_adding_defaults,
metadata_snapshot->getColumns(), context);
});

pipe_from_dst.addSimpleTransform([&](const Block & stream_header)
{
return std::make_shared<ConvertingTransform>(
stream_header, header, ConvertingTransform::MatchColumnsMode::Name);
});
}
}
}

Expand Down
@@ -0,0 +1 @@
a
12 changes: 12 additions & 0 deletions tests/queries/0_stateless/01514_empty_buffer_different_types.sql
@@ -0,0 +1,12 @@
set send_logs_level = 'error';

DROP TABLE IF EXISTS merge_tree_table1;
CREATE TABLE merge_tree_table1 (`s` LowCardinality(String), x UInt32) ENGINE = MergeTree ORDER BY x settings index_granularity = 1;
CREATE TABLE buffer_table1 ( `s` String , x UInt32) ENGINE = Buffer(currentDatabase(), 'merge_tree_table1', 16, 10, 60, 10, 1000, 1048576, 2097152);
SELECT s FROM buffer_table1;

insert into merge_tree_table1 values ('a', 1);
select s from buffer_table1 where x = 1;
select s from buffer_table1 where x = 2;

DROP TABLE IF EXISTS merge_tree_table1;

0 comments on commit 2305111

Please sign in to comment.