mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge pull request #11602 from ClickHouse/fix-buffer-sample
Fix buffer sample
This commit is contained in:
commit
d2be6c036b
@ -229,6 +229,17 @@ Pipes StorageBuffer::read(
|
||||
for (auto & buf : buffers)
|
||||
pipes_from_buffers.emplace_back(std::make_shared<BufferSource>(column_names, buf, *this));
|
||||
|
||||
/// Convert pipes from table to structure from buffer.
|
||||
if (!pipes_from_buffers.empty() && !pipes_from_dst.empty()
|
||||
&& !blocksHaveEqualStructure(pipes_from_buffers.front().getHeader(), pipes_from_dst.front().getHeader()))
|
||||
{
|
||||
for (auto & pipe : pipes_from_dst)
|
||||
pipe.addSimpleTransform(std::make_shared<ConvertingTransform>(
|
||||
pipe.getHeader(),
|
||||
pipes_from_buffers.front().getHeader(),
|
||||
ConvertingTransform::MatchColumnsMode::Name));
|
||||
}
|
||||
|
||||
/** If the sources from the table were processed before some non-initial stage of query execution,
|
||||
* then sources from the buffers must also be wrapped in the processing pipeline before the same stage.
|
||||
*/
|
||||
|
11
tests/queries/0_stateless/01305_buffer_final_bug.sql
Normal file
11
tests/queries/0_stateless/01305_buffer_final_bug.sql
Normal file
@ -0,0 +1,11 @@
|
||||
drop table if exists t;
|
||||
drop table if exists t_buf;
|
||||
|
||||
create table t (x UInt64) engine = MergeTree order by (x, intHash64(x)) sample by intHash64(x);
|
||||
insert into t select number from numbers(10000);
|
||||
create table t_buf as t engine = Buffer(currentDatabase(), 't', 16, 20, 100, 100000, 10000000, 50000000, 250000000);
|
||||
insert into t_buf values (1);
|
||||
select count() from t_buf sample 1/2 format Null;
|
||||
|
||||
drop table if exists t_buf;
|
||||
drop table if exists t;
|
Loading…
Reference in New Issue
Block a user