-
Notifications
You must be signed in to change notification settings - Fork 72
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
refactor: unify aggregate and window functions in window handling #170
Changes from all commits
b9d3c95
c5149a2
f5e33f5
4b7886d
6f8924b
38c97a2
00d52fc
082139c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,12 @@ | |
import com.google.protobuf.ByteString; | ||
import io.substrait.extension.SimpleExtension; | ||
import io.substrait.proto.AggregateFunction; | ||
import io.substrait.relation.Aggregate; | ||
import io.substrait.relation.Rel; | ||
import io.substrait.type.Type; | ||
import java.nio.ByteBuffer; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
import javax.annotation.Nullable; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Enclosing | ||
|
@@ -573,6 +570,42 @@ public <R, E extends Throwable> R accept(ExpressionVisitor<R, E> visitor) throws | |
} | ||
} | ||
|
||
@Value.Immutable | ||
abstract class WindowFunctionInvocation implements Expression { | ||
|
||
public abstract SimpleExtension.WindowFunctionVariant declaration(); | ||
|
||
public abstract List<FunctionArg> arguments(); | ||
|
||
public abstract Map<String, FunctionOption> options(); | ||
|
||
public abstract AggregationPhase aggregationPhase(); | ||
|
||
public abstract List<Expression> partitionBy(); | ||
|
||
public abstract List<SortField> sort(); | ||
|
||
public abstract WindowBound lowerBound(); | ||
|
||
public abstract WindowBound upperBound(); | ||
|
||
public abstract Type outputType(); | ||
|
||
public Type getType() { | ||
return outputType(); | ||
} | ||
|
||
public abstract AggregationInvocation invocation(); | ||
|
||
public static ImmutableExpression.WindowFunctionInvocation.Builder builder() { | ||
return ImmutableExpression.WindowFunctionInvocation.builder(); | ||
} | ||
|
||
public <R, E extends Throwable> R accept(ExpressionVisitor<R, E> visitor) throws E { | ||
return visitor.visit(this); | ||
} | ||
} | ||
|
||
@Value.Immutable | ||
abstract static class SingleOrList implements Expression { | ||
public abstract Expression condition(); | ||
|
@@ -684,41 +717,6 @@ public <R, E extends Throwable> R accept(ExpressionVisitor<R, E> visitor) throws | |
} | ||
} | ||
|
||
@Value.Immutable | ||
abstract static class Window implements Expression { | ||
@Nullable | ||
public abstract Aggregate.Measure aggregateFunction(); | ||
|
||
@Nullable | ||
public abstract WindowFunction windowFunction(); | ||
|
||
public abstract List<Expression> partitionBy(); | ||
|
||
public abstract List<SortField> orderBy(); | ||
|
||
public abstract WindowBound lowerBound(); | ||
|
||
public abstract WindowBound upperBound(); | ||
|
||
public abstract boolean hasNormalAggregateFunction(); | ||
|
||
public static ImmutableExpression.Window.Builder builder() { | ||
return ImmutableExpression.Window.builder(); | ||
} | ||
|
||
public <R, E extends Throwable> R accept(ExpressionVisitor<R, E> visitor) throws E { | ||
return visitor.visit(this); | ||
} | ||
} | ||
|
||
@Value.Immutable | ||
public abstract static class WindowFunction { | ||
public abstract WindowFunctionInvocation getFunction(); | ||
|
||
public abstract Optional<Expression> getPreMeasureFilter(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The I opted to remove it entirely. Support can be added in once the spec supports it. |
||
/** public static ImmutableMeasure.Builder builder() { return ImmutableMeasure.builder(); } */ | ||
} | ||
|
||
enum PredicateOp { | ||
PREDICATE_OP_UNSPECIFIED( | ||
io.substrait.proto.Expression.Subquery.SetPredicate.PredicateOp.PREDICATE_OP_UNSPECIFIED), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ public BoundedKind boundedKind() { | |
|
||
public abstract Direction direction(); | ||
|
||
public abstract Expression offset(); | ||
public abstract long offset(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the spec, offset must be The POJO layer should reflect this restriction. |
||
|
||
public static ImmutableWindowBound.BoundedWindowBound.Builder builder() { | ||
return ImmutableWindowBound.BoundedWindowBound.builder(); | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having separate handling for window calls with window functions, and window calls with aggregate functions, this PR updates the extension handling to treat all aggregate functions as valid window functions and a such removes the need for this distinction.