mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
fix crash in SummingMergeTree with LowCardinality
This commit is contained in:
parent
2054582a06
commit
fe90919f10
@ -266,17 +266,17 @@ static SummingSortedAlgorithm::ColumnsDefinition defineColumns(
|
||||
desc.is_agg_func_type = is_agg_func;
|
||||
desc.column_numbers = {i};
|
||||
|
||||
desc.real_type = column.type;
|
||||
desc.nested_type = recursiveRemoveLowCardinality(desc.real_type);
|
||||
if (desc.real_type.get() == desc.nested_type.get())
|
||||
desc.nested_type = nullptr;
|
||||
|
||||
if (simple)
|
||||
{
|
||||
// simple aggregate function
|
||||
desc.init(simple->getFunction(), true);
|
||||
if (desc.function->allocatesMemoryInArena())
|
||||
def.allocates_memory_in_arena = true;
|
||||
|
||||
desc.real_type = column.type;
|
||||
desc.nested_type = recursiveRemoveLowCardinality(desc.real_type);
|
||||
if (desc.real_type.get() == desc.nested_type.get())
|
||||
desc.nested_type = nullptr;
|
||||
}
|
||||
else if (!is_agg_func)
|
||||
{
|
||||
@ -395,14 +395,11 @@ static MutableColumns getMergedDataColumns(
|
||||
|
||||
columns.emplace_back(ColumnTuple::create(std::move(tuple_columns)));
|
||||
}
|
||||
else if (desc.is_simple_agg_func_type)
|
||||
else
|
||||
{
|
||||
const auto & type = desc.nested_type ? desc.nested_type
|
||||
: desc.real_type;
|
||||
const auto & type = desc.nested_type ? desc.nested_type : desc.real_type;
|
||||
columns.emplace_back(type->createColumn());
|
||||
}
|
||||
else
|
||||
columns.emplace_back(header.safeGetByPosition(desc.column_numbers[0]).column->cloneEmpty());
|
||||
}
|
||||
|
||||
for (const auto & column_number : def.column_numbers_not_to_aggregate)
|
||||
@ -421,7 +418,7 @@ static void preprocessChunk(Chunk & chunk, const SummingSortedAlgorithm::Columns
|
||||
|
||||
for (const auto & desc : def.columns_to_aggregate)
|
||||
{
|
||||
if (desc.is_simple_agg_func_type && desc.nested_type)
|
||||
if (desc.nested_type)
|
||||
{
|
||||
auto & col = columns[desc.column_numbers[0]];
|
||||
col = recursiveRemoveLowCardinality(col);
|
||||
@ -453,7 +450,7 @@ static void postprocessChunk(
|
||||
for (size_t i = 0; i < tuple_size; ++i)
|
||||
res_columns[desc.column_numbers[i]] = assert_cast<const ColumnTuple &>(*column).getColumnPtr(i);
|
||||
}
|
||||
else if (desc.is_simple_agg_func_type && desc.nested_type)
|
||||
else if (desc.nested_type)
|
||||
{
|
||||
const auto & from_type = desc.nested_type;
|
||||
const auto & to_type = desc.real_type;
|
||||
|
2
tests/queries/0_stateless/02456_summing_mt_lc.reference
Normal file
2
tests/queries/0_stateless/02456_summing_mt_lc.reference
Normal file
@ -0,0 +1,2 @@
|
||||
1 6 2020-01-01 00:00:00
|
||||
2 6 2020-01-02 00:00:00
|
20
tests/queries/0_stateless/02456_summing_mt_lc.sql
Normal file
20
tests/queries/0_stateless/02456_summing_mt_lc.sql
Normal file
@ -0,0 +1,20 @@
|
||||
SET allow_suspicious_low_cardinality_types = 1;
|
||||
|
||||
DROP TABLE IF EXISTS t_summing_lc;
|
||||
|
||||
CREATE TABLE t_summing_lc
|
||||
(
|
||||
`key` UInt32,
|
||||
`val` LowCardinality(UInt32),
|
||||
`date` DateTime
|
||||
)
|
||||
ENGINE = SummingMergeTree(val)
|
||||
PARTITION BY date
|
||||
ORDER BY key;
|
||||
|
||||
INSERT INTO t_summing_lc VALUES (1, 1, '2020-01-01'), (2, 1, '2020-01-02'), (1, 5, '2020-01-01'), (2, 5, '2020-01-02');
|
||||
|
||||
OPTIMIZE TABLE t_summing_lc FINAL;
|
||||
SELECT * FROM t_summing_lc ORDER BY key;
|
||||
|
||||
DROP TABLE t_summing_lc;
|
Loading…
Reference in New Issue
Block a user