-
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.
- Loading branch information
1 parent
0689c6b
commit c88d941
Showing
8 changed files
with
183 additions
and
0 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
75 changes: 75 additions & 0 deletions
75
core/src/main/java/io/substrait/relation/NestedLoopJoin.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,75 @@ | ||
package io.substrait.relation; | ||
|
||
import io.substrait.expression.Expression; | ||
import io.substrait.proto.NestedLoopJoinRel; | ||
import io.substrait.type.Type; | ||
import io.substrait.type.TypeCreator; | ||
import java.util.Optional; | ||
import java.util.stream.Stream; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
public abstract class NestedLoopJoin extends BiRel implements HasExtension { | ||
|
||
public abstract Optional<Expression> getCondition(); | ||
|
||
public abstract JoinType getJoinType(); | ||
|
||
public static enum JoinType { | ||
UNKNOWN(NestedLoopJoinRel.JoinType.JOIN_TYPE_UNSPECIFIED), | ||
INNER(NestedLoopJoinRel.JoinType.JOIN_TYPE_INNER), | ||
OUTER(NestedLoopJoinRel.JoinType.JOIN_TYPE_OUTER), | ||
LEFT(NestedLoopJoinRel.JoinType.JOIN_TYPE_LEFT), | ||
RIGHT(NestedLoopJoinRel.JoinType.JOIN_TYPE_RIGHT), | ||
LEFT_SEMI(NestedLoopJoinRel.JoinType.JOIN_TYPE_LEFT_SEMI), | ||
RIGHT_SEMI(NestedLoopJoinRel.JoinType.JOIN_TYPE_RIGHT_SEMI), | ||
LEFT_ANTI(NestedLoopJoinRel.JoinType.JOIN_TYPE_LEFT_ANTI), | ||
RIGHT_ANTI(NestedLoopJoinRel.JoinType.JOIN_TYPE_RIGHT_ANTI); | ||
|
||
private NestedLoopJoinRel.JoinType proto; | ||
|
||
JoinType(NestedLoopJoinRel.JoinType proto) { | ||
this.proto = proto; | ||
} | ||
|
||
public NestedLoopJoinRel.JoinType toProto() { | ||
return proto; | ||
} | ||
|
||
public static JoinType fromProto(NestedLoopJoinRel.JoinType proto) { | ||
for (var v : values()) { | ||
if (v.proto == proto) { | ||
return v; | ||
} | ||
} | ||
|
||
throw new IllegalArgumentException("Unknown type: " + proto); | ||
} | ||
} | ||
|
||
@Override | ||
protected Type.Struct deriveRecordType() { | ||
Stream<Type> leftTypes = | ||
switch (getJoinType()) { | ||
case RIGHT, RIGHT_SEMI, RIGHT_ANTI, OUTER -> getLeft().getRecordType().fields().stream() | ||
.map(TypeCreator::asNullable); | ||
default -> getLeft().getRecordType().fields().stream(); | ||
}; | ||
Stream<Type> rightTypes = | ||
switch (getJoinType()) { | ||
case LEFT, LEFT_SEMI, LEFT_ANTI, OUTER -> getRight().getRecordType().fields().stream() | ||
.map(TypeCreator::asNullable); | ||
default -> getRight().getRecordType().fields().stream(); | ||
}; | ||
return TypeCreator.REQUIRED.struct(Stream.concat(leftTypes, rightTypes)); | ||
} | ||
|
||
@Override | ||
public <O, E extends Exception> O accept(RelVisitor<O, E> visitor) throws E { | ||
return visitor.visit(this); | ||
} | ||
|
||
public static ImmutableNestedLoopJoin.Builder builder() { | ||
return ImmutableNestedLoopJoin.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
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