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: opening ProtoRelConverter for extension #285

Merged
merged 1 commit into from
Aug 9, 2024
Merged
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
53 changes: 27 additions & 26 deletions core/src/main/java/io/substrait/relation/ProtoRelConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public Rel from(io.substrait.proto.Rel rel) {
}
}

private Rel newRead(ReadRel rel) {
protected Rel newRead(ReadRel rel) {
if (rel.hasVirtualTable()) {
var virtualTable = rel.getVirtualTable();
if (virtualTable.getValuesCount() == 0) {
Expand All @@ -136,7 +136,7 @@ private Rel newRead(ReadRel rel) {
}
}

private Filter newFilter(FilterRel rel) {
protected Filter newFilter(FilterRel rel) {
var input = from(rel.getInput());
var builder =
Filter.builder()
Expand All @@ -154,7 +154,7 @@ private Filter newFilter(FilterRel rel) {
return builder.build();
}

private NamedStruct newNamedStruct(ReadRel rel) {
protected NamedStruct newNamedStruct(ReadRel rel) {
var namedStruct = rel.getBaseSchema();
var struct = namedStruct.getStruct();
return ImmutableNamedStruct.builder()
Expand All @@ -170,7 +170,7 @@ private NamedStruct newNamedStruct(ReadRel rel) {
.build();
}

private EmptyScan newEmptyScan(ReadRel rel) {
protected EmptyScan newEmptyScan(ReadRel rel) {
var namedStruct = newNamedStruct(rel);
var builder =
EmptyScan.builder()
Expand All @@ -192,7 +192,7 @@ private EmptyScan newEmptyScan(ReadRel rel) {
return builder.build();
}

private ExtensionLeaf newExtensionLeaf(ExtensionLeafRel rel) {
protected ExtensionLeaf newExtensionLeaf(ExtensionLeafRel rel) {
Extension.LeafRelDetail detail = detailFromExtensionLeafRel(rel.getDetail());
var builder =
ExtensionLeaf.from(detail)
Expand All @@ -201,7 +201,7 @@ private ExtensionLeaf newExtensionLeaf(ExtensionLeafRel rel) {
return builder.build();
}

private ExtensionSingle newExtensionSingle(ExtensionSingleRel rel) {
protected ExtensionSingle newExtensionSingle(ExtensionSingleRel rel) {
Extension.SingleRelDetail detail = detailFromExtensionSingleRel(rel.getDetail());
Rel input = from(rel.getInput());
var builder =
Expand All @@ -211,7 +211,7 @@ private ExtensionSingle newExtensionSingle(ExtensionSingleRel rel) {
return builder.build();
}

private ExtensionMulti newExtensionMulti(ExtensionMultiRel rel) {
protected ExtensionMulti newExtensionMulti(ExtensionMultiRel rel) {
Extension.MultiRelDetail detail = detailFromExtensionMultiRel(rel.getDetail());
List<Rel> inputs = rel.getInputsList().stream().map(this::from).collect(Collectors.toList());
var builder =
Expand All @@ -224,7 +224,7 @@ private ExtensionMulti newExtensionMulti(ExtensionMultiRel rel) {
return builder.build();
}

private NamedScan newNamedScan(ReadRel rel) {
protected NamedScan newNamedScan(ReadRel rel) {
var namedStruct = newNamedStruct(rel);
var builder =
NamedScan.builder()
Expand All @@ -247,7 +247,7 @@ private NamedScan newNamedScan(ReadRel rel) {
return builder.build();
}

private ExtensionTable newExtensionTable(ReadRel rel) {
protected ExtensionTable newExtensionTable(ReadRel rel) {
Extension.ExtensionTableDetail detail =
detailFromExtensionTable(rel.getExtensionTable().getDetail());
var builder = ExtensionTable.from(detail);
Expand All @@ -261,7 +261,7 @@ private ExtensionTable newExtensionTable(ReadRel rel) {
return builder.build();
}

private LocalFiles newLocalFiles(ReadRel rel) {
protected LocalFiles newLocalFiles(ReadRel rel) {
var namedStruct = newNamedStruct(rel);

var builder =
Expand All @@ -288,7 +288,7 @@ private LocalFiles newLocalFiles(ReadRel rel) {
return builder.build();
}

private FileOrFiles newFileOrFiles(ReadRel.LocalFiles.FileOrFiles file) {
protected FileOrFiles newFileOrFiles(ReadRel.LocalFiles.FileOrFiles file) {
ImmutableFileOrFiles.Builder builder =
ImmutableFileOrFiles.builder()
.partitionIndex(file.getPartitionIndex())
Expand Down Expand Up @@ -318,7 +318,7 @@ private FileOrFiles newFileOrFiles(ReadRel.LocalFiles.FileOrFiles file) {
return builder.build();
}

private VirtualTableScan newVirtualTable(ReadRel rel) {
protected VirtualTableScan newVirtualTable(ReadRel rel) {
var virtualTable = rel.getVirtualTable();
var virtualTableSchema = newNamedStruct(rel);
var converter =
Expand Down Expand Up @@ -349,7 +349,7 @@ private VirtualTableScan newVirtualTable(ReadRel rel) {
return builder.build();
}

private Fetch newFetch(FetchRel rel) {
protected Fetch newFetch(FetchRel rel) {
var input = from(rel.getInput());
var builder = Fetch.builder().input(input).offset(rel.getOffset());
if (rel.getCount() != -1) {
Expand All @@ -367,7 +367,7 @@ private Fetch newFetch(FetchRel rel) {
return builder.build();
}

private Project newProject(ProjectRel rel) {
protected Project newProject(ProjectRel rel) {
var input = from(rel.getInput());
var converter = new ProtoExpressionConverter(lookup, extensions, input.getRecordType(), this);
var builder =
Expand All @@ -387,7 +387,7 @@ private Project newProject(ProjectRel rel) {
return builder.build();
}

private Aggregate newAggregate(AggregateRel rel) {
protected Aggregate newAggregate(AggregateRel rel) {
var input = from(rel.getInput());
var protoExprConverter =
new ProtoExpressionConverter(lookup, extensions, input.getRecordType(), this);
Expand Down Expand Up @@ -432,7 +432,7 @@ private Aggregate newAggregate(AggregateRel rel) {
return builder.build();
}

private Sort newSort(SortRel rel) {
protected Sort newSort(SortRel rel) {
var input = from(rel.getInput());
var converter = new ProtoExpressionConverter(lookup, extensions, input.getRecordType(), this);
var builder =
Expand All @@ -457,7 +457,7 @@ private Sort newSort(SortRel rel) {
return builder.build();
}

private Join newJoin(JoinRel rel) {
protected Join newJoin(JoinRel rel) {
Rel left = from(rel.getLeft());
Rel right = from(rel.getRight());
Type.Struct leftStruct = left.getRecordType();
Expand All @@ -483,7 +483,7 @@ private Join newJoin(JoinRel rel) {
return builder.build();
}

private Rel newCross(CrossRel rel) {
protected Rel newCross(CrossRel rel) {
Rel left = from(rel.getLeft());
Rel right = from(rel.getRight());
var builder = Cross.builder().left(left).right(right);
Expand All @@ -497,7 +497,7 @@ private Rel newCross(CrossRel rel) {
return builder.build();
}

private Set newSet(SetRel rel) {
protected Set newSet(SetRel rel) {
List<Rel> inputs =
rel.getInputsList().stream()
.map(inputRel -> from(inputRel))
Expand All @@ -513,7 +513,7 @@ private Set newSet(SetRel rel) {
return builder.build();
}

private Rel newHashJoin(HashJoinRel rel) {
protected Rel newHashJoin(HashJoinRel rel) {
Rel left = from(rel.getLeft());
Rel right = from(rel.getRight());
var leftKeys = rel.getLeftKeysList();
Expand Down Expand Up @@ -545,7 +545,7 @@ private Rel newHashJoin(HashJoinRel rel) {
return builder.build();
}

private Rel newMergeJoin(MergeJoinRel rel) {
protected Rel newMergeJoin(MergeJoinRel rel) {
Rel left = from(rel.getLeft());
Rel right = from(rel.getRight());
var leftKeys = rel.getLeftKeysList();
Expand Down Expand Up @@ -577,7 +577,7 @@ private Rel newMergeJoin(MergeJoinRel rel) {
return builder.build();
}

private NestedLoopJoin newNestedLoopJoin(NestedLoopJoinRel rel) {
protected NestedLoopJoin newNestedLoopJoin(NestedLoopJoinRel rel) {
Rel left = from(rel.getLeft());
Rel right = from(rel.getRight());
Type.Struct leftStruct = left.getRecordType();
Expand All @@ -604,7 +604,8 @@ private NestedLoopJoin newNestedLoopJoin(NestedLoopJoinRel rel) {
return builder.build();
}

private ConsistentPartitionWindow newConsistentPartitionWindow(ConsistentPartitionWindowRel rel) {
protected ConsistentPartitionWindow newConsistentPartitionWindow(
ConsistentPartitionWindowRel rel) {

var input = from(rel.getInput());
var protoExpressionConverter =
Expand Down Expand Up @@ -639,20 +640,20 @@ private ConsistentPartitionWindow newConsistentPartitionWindow(ConsistentPartiti
return builder.build();
}

private static Optional<Rel.Remap> optionalRelmap(io.substrait.proto.RelCommon relCommon) {
protected static Optional<Rel.Remap> optionalRelmap(io.substrait.proto.RelCommon relCommon) {
return Optional.ofNullable(
relCommon.hasEmit() ? Rel.Remap.of(relCommon.getEmit().getOutputMappingList()) : null);
}

private Optional<AdvancedExtension> optionalAdvancedExtension(
protected Optional<AdvancedExtension> optionalAdvancedExtension(
io.substrait.proto.RelCommon relCommon) {
return Optional.ofNullable(
relCommon.hasAdvancedExtension()
? advancedExtension(relCommon.getAdvancedExtension())
: null);
}

private AdvancedExtension advancedExtension(
protected AdvancedExtension advancedExtension(
io.substrait.proto.AdvancedExtension advancedExtension) {
var builder = AdvancedExtension.builder();
if (advancedExtension.hasEnhancement()) {
Expand Down
Loading