Handle lowcardinality block in MergeJoin extractMinMax

This commit is contained in:
vdimir 2021-04-02 16:55:42 +03:00
parent 8f23d39f26
commit 8cd841c4ac
No known key found for this signature in database
GPG Key ID: F57B3E10A21DBB31
2 changed files with 8 additions and 4 deletions

View File

@ -86,10 +86,10 @@ Block extractMinMax(const Block & block, const Block & keys)
for (size_t i = 0; i < columns.size(); ++i)
{
const auto & src_column = block.getByName(keys.getByPosition(i).name);
columns[i]->insertFrom(*src_column.column, 0);
columns[i]->insertFrom(*src_column.column, block.rows() - 1);
const auto & src_column = block.getByName(min_max.getByPosition(i).name);
/// Cannot use insertFrom because src_column type can differ from keys, e.g. to be LowCardinality
columns[i]->insert((*src_column.column)[0]);
columns[i]->insert((*src_column.column)[block.rows() - 1]);
}
min_max.setColumns(std::move(columns));
@ -485,6 +485,7 @@ MergeJoin::MergeJoin(std::shared_ptr<TableJoin> table_join_, const Block & right
left_blocks_buffer = std::make_shared<SortedBlocksBuffer>(left_sort_description, max_bytes);
}
/// Has to be called event totals is empty
void MergeJoin::setTotals(const Block & totals_block)
{
totals = totals_block;

View File

@ -76,12 +76,15 @@ private:
Block right_table_keys;
Block right_columns_to_add;
SortedBlocksWriter::Blocks right_blocks;
/// Each block stores first and last row from corresponding sorted block on disk
Blocks min_max_right_blocks;
std::shared_ptr<SortedBlocksBuffer> left_blocks_buffer;
std::shared_ptr<RowBitmaps> used_rows_bitmap;
mutable std::unique_ptr<Cache> cached_right_blocks;
std::vector<std::shared_ptr<Block>> loaded_right_blocks;
std::unique_ptr<SortedBlocksWriter> disk_writer;
/// Set of files with sorted blocks
SortedBlocksWriter::SortedFiles flushed_right_blocks;
Block totals;
std::atomic<bool> is_in_memory{true};