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

chore: update to substrait 0.52.0 #282

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package io.substrait.extension;

import io.substrait.relation.Extension;
import java.util.List;
import java.util.Optional;
import org.immutables.value.Value;

@Value.Immutable
public abstract class AdvancedExtension {

public abstract Optional<Extension.Optimization> getOptimization();
public abstract List<Extension.Optimization> getOptimizations();

public abstract Optional<Extension.Enhancement> getEnhancement();

public io.substrait.proto.AdvancedExtension toProto() {
var builder = io.substrait.proto.AdvancedExtension.newBuilder();
getEnhancement().ifPresent(e -> builder.setEnhancement(e.toProto()));
getOptimization().ifPresent(e -> builder.setOptimization(e.toProto()));
getOptimizations().forEach(e -> builder.addOptimization(e.toProto()));
return builder.build();
}

Expand Down
11 changes: 7 additions & 4 deletions core/src/main/java/io/substrait/relation/ProtoRelConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -658,15 +658,18 @@ private AdvancedExtension advancedExtension(
if (advancedExtension.hasEnhancement()) {
builder.enhancement(enhancementFromAdvancedExtension(advancedExtension.getEnhancement()));
}
if (advancedExtension.hasOptimization()) {
builder.optimization(optimizationFromAdvancedExtension(advancedExtension.getOptimization()));
}
advancedExtension
.getOptimizationList()
.forEach(
optimization ->
builder.addOptimizations(optimizationFromAdvancedExtension(optimization)));

return builder.build();
}

/**
* Override to provide a custom converter for {@link
* io.substrait.proto.AdvancedExtension#getOptimization()} data
* io.substrait.proto.AdvancedExtension#getOptimizationList()} ()} data
*/
protected Extension.Optimization optimizationFromAdvancedExtension(com.google.protobuf.Any any) {
return new EmptyOptimization();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package io.substrait.relation.extensions;

import com.google.protobuf.Any;
import io.substrait.proto.AdvancedExtension;
import io.substrait.relation.Extension;

/**
* Default type to which {@link io.substrait.proto.AdvancedExtension#getOptimization()} data is
* converted to by the {@link io.substrait.relation.ProtoRelConverter}
* Default type to which {@link AdvancedExtension#getOptimizationList()} data is converted to by the
* {@link io.substrait.relation.ProtoRelConverter}
*/
public class EmptyOptimization implements Extension.Optimization {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ Rel relWithExtension(AdvancedExtension advancedExtension) {

Rel emptyAdvancedExtension = relWithExtension(AdvancedExtension.builder().build());
Rel advancedExtensionWithOptimization =
relWithExtension(AdvancedExtension.builder().optimization(OPTIMIZED).build());
relWithExtension(AdvancedExtension.builder().addOptimizations(OPTIMIZED).build());
Rel advancedExtensionWithEnhancement =
relWithExtension(AdvancedExtension.builder().enhancement(ENHANCED).build());
Rel advancedExtensionWithEnhancementAndOptimization =
relWithExtension(
AdvancedExtension.builder().enhancement(ENHANCED).optimization(OPTIMIZED).build());
AdvancedExtension.builder().enhancement(ENHANCED).addOptimizations(OPTIMIZED).build());

@Test
void emptyAdvancedExtension() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public class ExtensionRoundtripTest extends TestBase {
final AdvancedExtension commonExtension =
AdvancedExtension.builder()
.enhancement(new StringHolder("COMMON ENHANCEMENT"))
.optimization(new StringHolder("COMMON OPTIMIZATION"))
.addOptimizations(new StringHolder("COMMON OPTIMIZATION"))
.build();

final StringHolder detail = new StringHolder("DETAIL");

final AdvancedExtension relExtension =
AdvancedExtension.builder()
.enhancement(new StringHolder("REL ENHANCEMENT"))
.optimization(new StringHolder("REL OPTIMIZATION"))
.addOptimizations(new StringHolder("REL OPTIMIZATION"))
.build();

@Override
Expand Down
Loading