Fix error with batch aggregation and -Array combinator

This commit is contained in:
Alexey Milovidov 2020-08-14 09:52:28 +03:00
parent da8d8f35dd
commit 8c85ab3753
4 changed files with 42 additions and 17 deletions

View File

@ -388,13 +388,14 @@ public:
{
for (size_t j = 0; j < UNROLL_COUNT; ++j)
{
if (has_data[j * 256 + k])
size_t idx = j * 256 + k;
if (has_data[idx])
{
AggregateDataPtr & place = map[k];
if (unlikely(!place))
init(place);
func.merge(place + place_offset, reinterpret_cast<const char *>(&places[256 * j + k]), arena);
func.merge(place + place_offset, reinterpret_cast<const char *>(&places[idx]), nullptr);
}
}
}

View File

@ -449,7 +449,6 @@ void NO_INLINE Aggregator::executeImpl(
typename Method::State state(key_columns, key_sizes, aggregation_state_cache);
if (!no_more_keys)
//executeImplCase<false>(method, state, aggregates_pool, rows, aggregate_instructions, overflow_row);
executeImplBatch(method, state, aggregates_pool, rows, aggregate_instructions);
else
executeImplCase<true>(method, state, aggregates_pool, rows, aggregate_instructions, overflow_row);
@ -533,6 +532,19 @@ void NO_INLINE Aggregator::executeImplBatch(
/// Optimization for special case when aggregating by 8bit key.
if constexpr (std::is_same_v<Method, typename decltype(AggregatedDataVariants::key8)::element_type>)
{
/// We use another method if there are aggregate functions with -Array combinator.
bool has_arrays = false;
for (AggregateFunctionInstruction * inst = aggregate_instructions; inst->that; ++inst)
{
if (inst->offsets)
{
has_arrays = true;
break;
}
}
if (!has_arrays)
{
for (AggregateFunctionInstruction * inst = aggregate_instructions; inst->that; ++inst)
{
@ -551,6 +563,7 @@ void NO_INLINE Aggregator::executeImplBatch(
}
return;
}
}
/// Generic case.

View File

@ -0,0 +1,10 @@
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0

View File

@ -0,0 +1 @@
SELECT number % 100 AS k, sumArray(emptyArrayUInt8()) AS v FROM numbers(10) GROUP BY k;