-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ExpandRel support to core and Spark (#295)
feat(pojo): initial support for Hint messages feat(pojo): builder support for ExpandRel feat(spark): add mapping for any_value function feat(spark): add support for consuming NullLiteral expressions feat(spark): handle filter field on Measure
- Loading branch information
1 parent
5d66cd1
commit 32fea18
Showing
18 changed files
with
363 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.substrait.hint; | ||
|
||
import io.substrait.proto.RelCommon; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
public abstract class Hint { | ||
public abstract Optional<String> getAlias(); | ||
|
||
public abstract List<String> getOutputNames(); | ||
|
||
public RelCommon.Hint toProto() { | ||
var builder = RelCommon.Hint.newBuilder().addAllOutputNames(getOutputNames()); | ||
getAlias().ifPresent(builder::setAlias); | ||
return builder.build(); | ||
} | ||
|
||
public static ImmutableHint.Builder builder() { | ||
return ImmutableHint.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
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,62 @@ | ||
package io.substrait.relation; | ||
|
||
import io.substrait.expression.Expression; | ||
import io.substrait.type.Type; | ||
import io.substrait.type.TypeCreator; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Enclosing | ||
@Value.Immutable | ||
public abstract class Expand extends SingleInputRel { | ||
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Expand.class); | ||
|
||
public abstract List<ExpandField> getFields(); | ||
|
||
@Override | ||
public Type.Struct deriveRecordType() { | ||
Type.Struct initial = getInput().getRecordType(); | ||
return TypeCreator.of(initial.nullable()) | ||
.struct(Stream.concat(initial.fields().stream(), Stream.of(TypeCreator.REQUIRED.I64))); | ||
} | ||
|
||
@Override | ||
public <O, E extends Exception> O accept(RelVisitor<O, E> visitor) throws E { | ||
return visitor.visit(this); | ||
} | ||
|
||
public static ImmutableExpand.Builder builder() { | ||
return ImmutableExpand.builder(); | ||
} | ||
|
||
public interface ExpandField { | ||
Type getType(); | ||
} | ||
|
||
@Value.Immutable | ||
public abstract static class ConsistentField implements ExpandField { | ||
public abstract Expression getExpression(); | ||
|
||
public Type getType() { | ||
return getExpression().getType(); | ||
} | ||
|
||
public static ImmutableExpand.ConsistentField.Builder builder() { | ||
return ImmutableExpand.ConsistentField.builder(); | ||
} | ||
} | ||
|
||
@Value.Immutable | ||
public abstract static class SwitchingField implements ExpandField { | ||
public abstract List<Expression> getDuplicates(); | ||
|
||
public Type getType() { | ||
return getDuplicates().get(0).getType(); | ||
} | ||
|
||
public static ImmutableExpand.SwitchingField.Builder builder() { | ||
return ImmutableExpand.SwitchingField.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
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
Oops, something went wrong.