substrait-io / substrait-java

Apache License 2.0
74 stars 70 forks source link

proposal: any type handling #133

Closed vbarua closed 1 year ago

vbarua commented 1 year ago

This PR is split into two commits:

Summary

com.protobuf.Any types are handled by methods in the ProtoRelConverter that are intended to be overriden by end users. For example:

public class ProtoRelConverter {
  ...  
  protected Extension.Optimization optimizationFromAdvancedExtension(com.google.protobuf.Any any)
  ...
}

can be overriden by end users to convert the Any into their own Java equivalent.

Extension.Optimization is a tag interface to be able to distinguish between various types of Any data (instead of having Object everywhere).

/** Contains tag interfaces for handling {@link com.google.protobuf.Any} types within Substrait. */
public class Extension {

  private interface ToProto {
    com.google.protobuf.Any toProto();
  }

  public interface Optimization extends ToProto {}
 ...
JamesRTaylor commented 1 year ago

This is really cool! Thanks so much for putting it together, @vbarua. What do you think would be a good real world use case for this feature?

vbarua commented 1 year ago

@JamesRTaylor

What do you think would be a good real world use case for this feature?

Well, some of the stuff we want to use it for:

vbarua commented 1 year ago

Superceded by https://github.com/substrait-io/substrait-java/pull/135