-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pojo): add POJO representation and converters for ConsistentPart…
…itionWindowRel (#231)
- Loading branch information
Showing
10 changed files
with
411 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
core/src/main/java/io/substrait/relation/ConsistentPartitionWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package io.substrait.relation; | ||
|
||
import io.substrait.expression.Expression; | ||
import io.substrait.expression.Expression.SortField; | ||
import io.substrait.expression.FunctionArg; | ||
import io.substrait.expression.FunctionOption; | ||
import io.substrait.expression.WindowBound; | ||
import io.substrait.extension.SimpleExtension; | ||
import io.substrait.type.Type; | ||
import io.substrait.type.TypeCreator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
@Value.Enclosing | ||
public abstract class ConsistentPartitionWindow extends SingleInputRel implements HasExtension { | ||
|
||
public abstract List<WindowRelFunctionInvocation> getWindowFunctions(); | ||
|
||
public abstract List<Expression> getPartitionExpressions(); | ||
|
||
public abstract List<SortField> getSorts(); | ||
|
||
@Override | ||
protected Type.Struct deriveRecordType() { | ||
Type.Struct initial = getInput().getRecordType(); | ||
return TypeCreator.of(initial.nullable()) | ||
.struct( | ||
Stream.concat( | ||
initial.fields().stream(), | ||
getPartitionExpressions().stream().map(Expression::getType))); | ||
} | ||
|
||
@Override | ||
public <O, E extends Exception> O accept(RelVisitor<O, E> visitor) throws E { | ||
return visitor.visit(this); | ||
} | ||
|
||
public static ImmutableConsistentPartitionWindow.Builder builder() { | ||
return ImmutableConsistentPartitionWindow.builder(); | ||
} | ||
|
||
@Value.Immutable | ||
public abstract static class WindowRelFunctionInvocation { | ||
|
||
public abstract SimpleExtension.WindowFunctionVariant declaration(); | ||
|
||
public abstract List<FunctionArg> arguments(); | ||
|
||
public abstract Map<String, FunctionOption> options(); | ||
|
||
public abstract Type outputType(); | ||
|
||
public abstract Expression.AggregationPhase aggregationPhase(); | ||
|
||
public abstract Expression.AggregationInvocation invocation(); | ||
|
||
public abstract WindowBound lowerBound(); | ||
|
||
public abstract WindowBound upperBound(); | ||
|
||
public abstract Expression.WindowBoundsType boundsType(); | ||
|
||
public static ImmutableConsistentPartitionWindow.WindowRelFunctionInvocation.Builder builder() { | ||
return ImmutableConsistentPartitionWindow.WindowRelFunctionInvocation.builder(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.