Skip to content

Commit

Permalink
spark sql sum(real) return type is double
Browse files Browse the repository at this point in the history
  • Loading branch information
JkSelf committed May 15, 2024
1 parent 54db952 commit 173f521
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion velox/functions/sparksql/aggregates/SumAggregate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ exec::AggregateRegistrationResult registerSum(
bool overwrite) {
std::vector<std::shared_ptr<exec::AggregateFunctionSignature>> signatures{
exec::AggregateFunctionSignatureBuilder()
.returnType("real")
.returnType("double")
.intermediateType("double")
.argumentType("real")
.build(),
Expand Down
11 changes: 11 additions & 0 deletions velox/functions/sparksql/aggregates/tests/SumAggregationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,5 +449,16 @@ TEST_F(SumAggregationTest, decimalRangeOverflow) {
{expected},
{});
}

TEST_F(SumAggregationTest, sumFloat) {
auto data = makeRowVector({makeFlatVector<float>({2.00, 1.00})});
createDuckDbTable({data});

testAggregations(
[&](auto& builder) { builder.values({data}); },
{},
{"spark_sum(c0)"},
"SELECT sum(c0) FROM tmp");
}
} // namespace
} // namespace facebook::velox::functions::aggregate::sparksql::test

0 comments on commit 173f521

Please sign in to comment.