Skip to content

Commit c8b771d

Browse files
rui-mozhztheplayer
authored andcommitted
Fix decimal agg signature on partial companion function (#465)
1 parent 2263b5d commit c8b771d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

velox/functions/sparksql/aggregates/AverageAggregate.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,9 @@ exec::AggregateRegistrationResult registerAverage(
429429
auto inputScale = inputType->asShortDecimal().scale();
430430
auto sumType =
431431
DECIMAL(std::min(38, inputPrecision + 10), inputScale);
432-
if (exec::isPartialOutput(step)) {
432+
if (exec::isPartialOutput(step) ||
433+
(step == core::AggregationNode::Step::kSingle &&
434+
resultType->isRow())) {
433435
return std::make_unique<
434436
DecimalAverageAggregate<int64_t, int64_t>>(
435437
resultType, sumType);

velox/functions/sparksql/aggregates/SumAggregate.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ using SumAggregate = SumAggregateBase<TInput, TAccumulator, ResultType, true>;
2929
TypePtr getDecimalSumType(
3030
const TypePtr& resultType,
3131
core::AggregationNode::Step step) {
32-
return exec::isPartialOutput(step) ? resultType->childAt(0) : resultType;
32+
if (exec::isPartialOutput(step)) {
33+
return resultType->childAt(0);
34+
}
35+
if (step == core::AggregationNode::Step::kSingle && resultType->isRow()) {
36+
return resultType->childAt(0);
37+
}
38+
return resultType;
3339
}
3440
} // namespace
3541

0 commit comments

Comments
 (0)