mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-20 05:05:38 +00:00
Fix crash with Variant + AggregateFunction type
This commit is contained in:
parent
397a523971
commit
cd06945a03
@ -330,7 +330,11 @@ ColumnPtr ColumnAggregateFunction::filter(const Filter & filter, ssize_t result_
|
|||||||
|
|
||||||
void ColumnAggregateFunction::expand(const Filter & mask, bool inverted)
|
void ColumnAggregateFunction::expand(const Filter & mask, bool inverted)
|
||||||
{
|
{
|
||||||
expandDataByMask<char *>(data, mask, inverted);
|
ensureOwnership();
|
||||||
|
Arena & arena = createOrGetArena();
|
||||||
|
char * default_ptr = arena.alignedAlloc(func->sizeOfData(), func->alignOfData());
|
||||||
|
func->create(default_ptr);
|
||||||
|
expandDataByMask<char *>(data, mask, inverted, default_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnPtr ColumnAggregateFunction::permute(const Permutation & perm, size_t limit) const
|
ColumnPtr ColumnAggregateFunction::permute(const Permutation & perm, size_t limit) const
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
500
|
||||||
|
fail 500
|
||||||
|
499
|
||||||
|
fail 500
|
||||||
|
500 499
|
||||||
|
fail 500 500
|
@ -0,0 +1,60 @@
|
|||||||
|
SET allow_experimental_variant_type = 1;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS source;
|
||||||
|
CREATE TABLE source
|
||||||
|
(
|
||||||
|
Name String,
|
||||||
|
Value Int64
|
||||||
|
|
||||||
|
) ENGINE = MergeTree ORDER BY ();
|
||||||
|
|
||||||
|
INSERT INTO source SELECT ['fail', 'success'][number % 2] as Name, number AS Value FROM numbers(1000);
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS test_agg_variant;
|
||||||
|
CREATE TABLE test_agg_variant
|
||||||
|
(
|
||||||
|
Name String,
|
||||||
|
Value Variant(AggregateFunction(uniqExact, Int64), AggregateFunction(avg, Int64))
|
||||||
|
)
|
||||||
|
ENGINE = MergeTree
|
||||||
|
ORDER BY (Name);
|
||||||
|
|
||||||
|
INSERT INTO test_agg_variant
|
||||||
|
SELECT
|
||||||
|
Name,
|
||||||
|
t AS Value
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
Name,
|
||||||
|
arrayJoin([
|
||||||
|
uniqExactState(Value)::Variant(AggregateFunction(uniqExact, Int64), AggregateFunction(avg, Int64)),
|
||||||
|
avgState(Value)::Variant(AggregateFunction(uniqExact, Int64), AggregateFunction(avg, Int64))
|
||||||
|
]) AS t
|
||||||
|
FROM source
|
||||||
|
GROUP BY Name
|
||||||
|
);
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
Name,
|
||||||
|
uniqExactMerge(Value.`AggregateFunction(uniqExact, Int64)`) AS Value
|
||||||
|
FROM test_agg_variant
|
||||||
|
GROUP BY Name;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
Name,
|
||||||
|
avgMerge(Value.`AggregateFunction(avg, Int64)`) AS Value
|
||||||
|
FROM test_agg_variant
|
||||||
|
GROUP BY Name;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
Name,
|
||||||
|
uniqExactMerge(Value.`AggregateFunction(uniqExact, Int64)`) AS ValueUniq,
|
||||||
|
avgMerge(Value.`AggregateFunction(avg, Int64)`) AS ValueAvg
|
||||||
|
FROM test_agg_variant
|
||||||
|
GROUP BY Name;
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE test_agg_variant;
|
||||||
|
DROP TABLE source;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user