handle virtual row in BufferChunksTransform

This commit is contained in:
jsc0218 2024-09-17 15:06:21 +00:00
parent 6af5fe48ba
commit 81a7927b8a
3 changed files with 15 additions and 7 deletions

View File

@ -1,4 +1,5 @@
#include <Processors/QueryPlan/BufferChunksTransform.h>
#include <Processors/Merges/Algorithms/MergeTreeReadInfo.h>
namespace DB
{
@ -49,13 +50,26 @@ IProcessor::Status BufferChunksTransform::prepare()
else if (input.hasData())
{
auto chunk = pullChunk();
bool virtual_row = getVirtualRowFromChunk(chunk);
output.push(std::move(chunk));
if (virtual_row)
{
input.setNotNeeded();
return Status::PortFull;
}
}
}
if (input.hasData() && (num_buffered_rows < max_rows_to_buffer || num_buffered_bytes < max_bytes_to_buffer))
{
auto chunk = pullChunk();
bool virtual_row = getVirtualRowFromChunk(chunk);
if (virtual_row)
{
output.push(std::move(chunk));
input.setNotNeeded();
return Status::PortFull;
}
num_buffered_rows += chunk.getNumRows();
num_buffered_bytes += chunk.bytes();
chunks.push(std::move(chunk));

View File

@ -825,9 +825,7 @@ InputOrderInfoPtr buildInputOrderInfo(SortingStep & sorting, QueryPlan::Node & n
if (!can_read)
return nullptr;
bool use_buffering = (order_info->limit == 0) && sorting.getSettings().read_in_order_use_buffering;
/// Avoid conflict with buffering.
if (!use_buffering && !order_info->first_prefix_fixed)
if (!order_info->first_prefix_fixed)
reading->enableVirtualRow();
}

View File

@ -108,7 +108,6 @@ ORDER BY x ASC
LIMIT 4
SETTINGS max_block_size = 8192,
read_in_order_two_level_merge_threshold = 5, --avoid preliminary merge
read_in_order_use_buffering = false, --avoid buffer
max_threads = 1,
optimize_read_in_order = 1,
log_comment = 'no preliminary merge, with filter';
@ -143,7 +142,6 @@ FROM fixed_prefix
WHERE a = 1
ORDER BY b
SETTINGS max_threads = 1,
read_in_order_use_buffering = false,
optimize_read_in_order = 1,
read_in_order_two_level_merge_threshold = 0; --force preliminary merge
@ -152,7 +150,6 @@ FROM fixed_prefix
WHERE a = 1
ORDER BY b
SETTINGS max_threads = 1,
read_in_order_use_buffering = false,
optimize_read_in_order = 1,
read_in_order_two_level_merge_threshold = 5; --avoid preliminary merge
@ -181,7 +178,6 @@ FROM function_pk
ORDER BY (A,-B) ASC
limit 3
SETTINGS max_threads = 1,
read_in_order_use_buffering = false,
optimize_read_in_order = 1,
read_in_order_two_level_merge_threshold = 0; --force preliminary merge