Skip to content

Commit

Permalink
Remove implicit fall through in Spark SumAggregates (facebookincubato…
Browse files Browse the repository at this point in the history
…r#9081)

Summary:
An implicit fall through was detected in SumAggregates.cpp ; Implicit fallthroughs have a very high bug rate, so they  are being made a compiler error by default. This change removes the implicit fall through by adding a VELOX_CHECK and removing the if.

Pull Request resolved: facebookincubator#9081

Reviewed By: mbasmanova, r-barnes

Differential Revision: D54904041

Pulled By: kgpai

fbshipit-source-id: c01013cfca30c11dec9e08747a83636f35ed9ce4
  • Loading branch information
kgpai authored and facebook-github-bot committed Mar 14, 2024
1 parent 177ff56 commit 704113a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions velox/experimental/wave/exec/WaveOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void WaveOperator::definesSubfields(
defines_[Value(field)] = operand;
}
}
[[fallthrough]];
// TODO:Add cases for nested types.
default: {
return;
Expand Down
1 change: 1 addition & 0 deletions velox/functions/sparksql/aggregates/AverageAggregate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ exec::AggregateRegistrationResult registerAverage(
return std::make_unique<DecimalAverageAggregateBase<int64_t>>(
resultType);
}
[[fallthrough]];
default:
VELOX_FAIL(
"Unsupported result type for final aggregation: {}",
Expand Down
12 changes: 6 additions & 6 deletions velox/functions/sparksql/aggregates/SumAggregate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,11 @@ exec::AggregateRegistrationResult registerSum(
BIGINT());
}
case TypeKind::HUGEINT: {
if (inputType->isLongDecimal()) {
// If inputType is long decimal,
// its output type is always long decimal.
return std::make_unique<exec::SimpleAggregateAdapter<
DecimalSumAggregate<int128_t, int128_t>>>(resultType);
}
VELOX_CHECK(inputType->isLongDecimal());
// If inputType is long decimal,
// its output type is always long decimal.
return std::make_unique<exec::SimpleAggregateAdapter<
DecimalSumAggregate<int128_t, int128_t>>>(resultType);
}
case TypeKind::REAL:
if (resultType->kind() == TypeKind::REAL) {
Expand Down Expand Up @@ -147,6 +146,7 @@ exec::AggregateRegistrationResult registerSum(
DecimalSumAggregate<int128_t, int128_t>>>(resultType);
}
}
[[fallthrough]];
default:
VELOX_CHECK(
false,
Expand Down
1 change: 1 addition & 0 deletions velox/vector/tests/VectorSaverTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class VectorSaverTest : public testing::Test, public VectorTestBase {
// different values in its flat children of size 1.
break;
}
[[fallthrough]];
case VectorEncoding::Simple::DICTIONARY:
if (expected->valueVector()) {
ASSERT_TRUE(actual->valueVector() != nullptr);
Expand Down

0 comments on commit 704113a

Please sign in to comment.