Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pojo): add UNSPECIFIED value to AggregationPhase enum #320

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/main/java/io/substrait/expression/Expression.java
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ public static AggregationInvocation fromProto(AggregateFunction.AggregationInvoc
}

enum AggregationPhase {
UNSPECIFIED(io.substrait.proto.AggregationPhase.AGGREGATION_PHASE_UNSPECIFIED),
Copy link
Member

@EpsilonPrime EpsilonPrime Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are probably a lot of switches that need to be updated as appropriate. A search for INITIAL_TO_RESULT found many potential instances across Java and Scala.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enumerations here are mapping from the protobuf enumerations; in this case here one of the valid values in the protobuf was missing from the Java enumerations;

If a plan contained that it would fail immediately; which in the case of a plan coming from duckdb it did.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are probably a lot of switches that need to be updated as appropriate.

There's actually a Java warning enabled for exhaustive switch statements, which should trigger CI failures. I didn't see any pattern matching blocks in Java which would be affected.

I did find one in Scala running ./gradlew check locally. I filed #321 for the fact that it didn't fail in CI.

INITIAL_TO_INTERMEDIATE(
io.substrait.proto.AggregationPhase.AGGREGATION_PHASE_INITIAL_TO_INTERMEDIATE),
INTERMEDIATE_TO_INTERMEDIATE(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ object ToAggregateFunction {
case other => throw new UnsupportedOperationException(s"not currently supported: $other.")
}
def toSpark(phase: SExpression.AggregationPhase): AggregateMode = phase match {
case SExpression.AggregationPhase.UNSPECIFIED =>
Final // UNSPECIFIED implies INTERMEDIATE_TO_RESULT
case SExpression.AggregationPhase.INITIAL_TO_INTERMEDIATE => Partial
case SExpression.AggregationPhase.INTERMEDIATE_TO_INTERMEDIATE => PartialMerge
case SExpression.AggregationPhase.INTERMEDIATE_TO_RESULT => Final
Expand Down
Loading