dbms: fixed error when sorting result of ARRAY JOIN by empty arrays [#METR-13204].

This commit is contained in:
Alexey Milovidov 2014-10-14 22:39:38 +04:00
parent 5fc32bb267
commit 1c16466214
3 changed files with 16 additions and 7 deletions

View File

@ -47,16 +47,23 @@ Block MergeSortingBlockInputStream::merge(Blocks & blocks)
bool has_collation = false;
size_t i = 0;
for (Blocks::const_iterator it = blocks.begin(); it != blocks.end(); ++it, ++i)
size_t nonempty_blocks = 0;
for (Blocks::const_iterator it = blocks.begin(); it != blocks.end(); ++it)
{
if (!*it)
if (it->rowsInFirstColumn() == 0)
continue;
cursors[i] = SortCursorImpl(*it, description);
has_collation |= cursors[i].has_collation;
cursors[nonempty_blocks] = SortCursorImpl(*it, description);
has_collation |= cursors[nonempty_blocks].has_collation;
++nonempty_blocks;
}
if (nonempty_blocks == 0)
return Block();
cursors.resize(nonempty_blocks);
Block merged;
if (has_collation)

View File

@ -22,7 +22,7 @@ void MergingSortedBlockInputStream::init(Block & merged_block, ColumnPlainPtrs &
*it = children[i]->read();
if (!*it)
if (it->rowsInFirstColumn() == 0)
continue;
if (!num_columns)

View File

@ -0,0 +1,2 @@
SET max_block_size = 1;
SELECT number, arr FROM (SELECT number, arrayFilter(x -> x = 0, [1]) AS arr FROM system.numbers LIMIT 10) ARRAY JOIN arr ORDER BY number;