mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
JIT sort description crash fix
This commit is contained in:
parent
0d153094d5
commit
8d9541b8d7
@ -47,16 +47,6 @@ void MergingSortedAlgorithm::addInput()
|
||||
cursors.emplace_back();
|
||||
}
|
||||
|
||||
static void prepareChunk(Chunk & chunk)
|
||||
{
|
||||
auto num_rows = chunk.getNumRows();
|
||||
auto columns = chunk.detachColumns();
|
||||
for (auto & column : columns)
|
||||
column = column->convertToFullColumnIfConst();
|
||||
|
||||
chunk.setColumns(std::move(columns), num_rows);
|
||||
}
|
||||
|
||||
void MergingSortedAlgorithm::initialize(Inputs inputs)
|
||||
{
|
||||
current_inputs = std::move(inputs);
|
||||
@ -68,7 +58,7 @@ void MergingSortedAlgorithm::initialize(Inputs inputs)
|
||||
if (!chunk)
|
||||
continue;
|
||||
|
||||
prepareChunk(chunk);
|
||||
convertToFullIfConst(chunk);
|
||||
cursors[source_num] = SortCursorImpl(header, chunk.getColumns(), description, source_num);
|
||||
}
|
||||
|
||||
@ -92,7 +82,7 @@ void MergingSortedAlgorithm::initialize(Inputs inputs)
|
||||
|
||||
void MergingSortedAlgorithm::consume(Input & input, size_t source_num)
|
||||
{
|
||||
prepareChunk(input.chunk);
|
||||
convertToFullIfConst(input.chunk);
|
||||
current_inputs[source_num].swap(input);
|
||||
cursors[source_num].reset(current_inputs[source_num].chunk.getColumns(), header);
|
||||
|
||||
|
@ -39,6 +39,9 @@ MergeSorter::MergeSorter(const Block & header, Chunks chunks_, SortDescription &
|
||||
/// which can be inefficient.
|
||||
convertToFullIfSparse(chunk);
|
||||
|
||||
/// Convert to full column, because some cursors expect non-contant columns
|
||||
convertToFullIfConst(chunk);
|
||||
|
||||
cursors.emplace_back(header, chunk.getColumns(), description, chunk_index);
|
||||
has_collation |= cursors.back().has_collation;
|
||||
|
||||
|
@ -0,0 +1,25 @@
|
||||
5
|
||||
--
|
||||
5
|
||||
--
|
||||
2 5
|
||||
2 5
|
||||
|
||||
2 5
|
||||
--
|
||||
2 5
|
||||
2 5
|
||||
|
||||
2 5
|
||||
--
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
--
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
@ -0,0 +1,47 @@
|
||||
SET allow_deprecated_syntax_for_merge_tree = 1;
|
||||
SET compile_sort_description = 1;
|
||||
SET min_count_to_compile_sort_description = 0;
|
||||
|
||||
DROP TABLE IF EXISTS test1_00395;
|
||||
CREATE TABLE test1_00395
|
||||
(
|
||||
col1 UInt64,
|
||||
col2 Nullable(UInt64),
|
||||
col3 String,
|
||||
col4 Nullable(String),
|
||||
col5 Array(UInt64),
|
||||
col6 Array(Nullable(UInt64)),
|
||||
col7 Array(String),
|
||||
col8 Array(Nullable(String)),
|
||||
d Date
|
||||
) Engine = MergeTree(d, (col1, d), 8192);
|
||||
|
||||
INSERT INTO test1_00395 VALUES (1, 1, 'a', 'a', [1], [1], ['a'], ['a'], '2000-01-01');
|
||||
INSERT INTO test1_00395 VALUES (1, NULL, 'a', 'a', [1], [1], ['a'], ['a'], '2000-01-01');
|
||||
INSERT INTO test1_00395 VALUES (1, 1, 'a', NULL, [1], [1], ['a'], ['a'], '2000-01-01');
|
||||
INSERT INTO test1_00395 VALUES (1, 1, 'a', 'a', [1], [NULL], ['a'], ['a'], '2000-01-01');
|
||||
INSERT INTO test1_00395 VALUES (1, 1, 'a', 'a', [1], [1], ['a'], [NULL], '2000-01-01');
|
||||
|
||||
SELECT count(greatest(multiIf(1, 2, toNullable(NULL), 3, 4))) FROM test1_00395 WHERE toNullable(27) GROUP BY col1 ORDER BY multiIf(27, 1, multiIf(materialize(1), toLowCardinality(2), 3, 1, 4), NULL, 4) ASC NULLS LAST, col1 DESC;
|
||||
|
||||
SELECT '--';
|
||||
|
||||
SELECT count(greatest(multiIf(1, 2, toNullable(NULL), 3, 4))) FROM test1_00395 WHERE toNullable(27) GROUP BY col1 ORDER BY multiIf(27, 1, multiIf(materialize(1), toLowCardinality(2), 3, 1, 4), NULL, 4) ASC NULLS LAST, col1 DESC;
|
||||
|
||||
SELECT '--';
|
||||
|
||||
SELECT multiIf(1, 2, NULL, 3, 4), count(greatest(multiIf(1, 2, NULL, toUInt256(3), 4), multiIf(1, 2, NULL, 3, 4))) FROM test1_00395 GROUP BY col1 WITH CUBE WITH TOTALS ORDER BY multiIf(27, 1, multiIf(materialize(1), toLowCardinality(2), 3, 1, 4), NULL, 4) ASC NULLS LAST;
|
||||
|
||||
SELECT '--';
|
||||
|
||||
SELECT multiIf(1, 2, NULL, 3, 4), count(greatest(multiIf(1, 2, NULL, toUInt256(3), 4), multiIf(1, 2, NULL, 3, 4))) FROM test1_00395 GROUP BY col1 WITH CUBE WITH TOTALS ORDER BY multiIf(27, 1, multiIf(materialize(1), toLowCardinality(2), 3, 1, 4), NULL, 4) ASC NULLS LAST;
|
||||
|
||||
SELECT '--';
|
||||
|
||||
SELECT col1 FROM test1_00395 ORDER BY multiIf(27, 1, multiIf(materialize(1), toLowCardinality(2), 3, 1, 4), NULL, 4) ASC;
|
||||
|
||||
SELECT '--';
|
||||
|
||||
SELECT col1 FROM test1_00395 ORDER BY multiIf(27, 1, multiIf(materialize(1), toLowCardinality(2), 3, 1, 4), NULL, 4) ASC;
|
||||
|
||||
DROP TABLE test1_00395;
|
Loading…
Reference in New Issue
Block a user