diff --git a/core/src/main/java/io/substrait/extension/SimpleExtension.java b/core/src/main/java/io/substrait/extension/SimpleExtension.java
index c2c2298b0..e494aa1a8 100644
--- a/core/src/main/java/io/substrait/extension/SimpleExtension.java
+++ b/core/src/main/java/io/substrait/extension/SimpleExtension.java
@@ -105,6 +105,18 @@ public enum WindowType {
STREAMING
}
+ /**
+ * Enumerates how functions supporting the system-preferred variation relate to a type variation.
+ */
+ public enum TypeVariationFunctionBehavior {
+ /**
+ * Functions that support the system-preferred variation implicitly also support this variation.
+ */
+ INHERITS,
+ /** Functions must be resolved independently for this variation. */
+ SEPARATE
+ }
+
private SimpleExtension() {}
/** Describes an argument provided by a simple extension. */
@@ -372,6 +384,21 @@ static TypeAnchor of(String urn, String name) {
}
}
+ /** Describes a type variation anchor provided by a simple extension. */
+ @Value.Immutable
+ public interface TypeVariationAnchor extends Anchor {
+ /**
+ * Creates the corresponding of instance.
+ *
+ * @param urn the urn
+ * @param name the name
+ * @return the of
+ */
+ static TypeVariationAnchor of(String urn, String name) {
+ return ImmutableSimpleExtension.TypeVariationAnchor.builder().urn(urn).key(name).build();
+ }
+ }
+
/** Describes a variadic behavior provided by a simple extension. */
@JsonDeserialize(as = ImmutableSimpleExtension.VariadicBehavior.class)
@JsonSerialize(as = ImmutableSimpleExtension.VariadicBehavior.class)
@@ -1061,6 +1088,81 @@ public TypeAnchor getAnchor() {
}
}
+ /**
+ * Describes a type variation declared by a simple extension.
+ *
+ *
A type variation represents an alternative representation of a base type class (e.g. a
+ * dictionary-encoded string), as defined by the {@code type_variations} section of the simple
+ * extension schema.
+ */
+ @JsonDeserialize(as = ImmutableSimpleExtension.TypeVariation.class)
+ @JsonSerialize(as = ImmutableSimpleExtension.TypeVariation.class)
+ @Value.Immutable
+ public abstract static class TypeVariation {
+ private final Supplier anchorSupplier =
+ Util.memoize(() -> TypeVariationAnchor.of(urn(), name()));
+
+ /**
+ * Returns the name.
+ *
+ * @return the name
+ */
+ public abstract String name();
+
+ /**
+ * Returns the base type class of this variation as written in the extension file (e.g. {@code
+ * string} or {@code struct}).
+ *
+ * @return the parent type class
+ */
+ @JsonProperty("parent")
+ public abstract String parent();
+
+ /**
+ * Returns the description.
+ *
+ * @return the description
+ */
+ public abstract Optional description();
+
+ /**
+ * Returns the function behavior, i.e. whether functions supporting the system-preferred
+ * variation implicitly support this variation ({@code INHERITS}) or must be resolved
+ * independently ({@code SEPARATE}). Defaults to {@code INHERITS}.
+ *
+ * @return the function behavior
+ */
+ @Value.Default
+ @JsonProperty("functions")
+ public TypeVariationFunctionBehavior functions() {
+ return TypeVariationFunctionBehavior.INHERITS;
+ }
+
+ /**
+ * Returns the deprecated.
+ *
+ * @return the deprecated
+ */
+ public abstract Optional deprecated();
+
+ /**
+ * Returns the urn.
+ *
+ * @return the urn
+ */
+ @JacksonInject(SimpleExtension.URN_LOCATOR_KEY)
+ public abstract String urn();
+
+ /**
+ * Returns the anchor.
+ *
+ * @return the anchor
+ */
+ public TypeVariationAnchor getAnchor() {
+ return anchorSupplier.get();
+ }
+ }
+
/** Describes an extension signatures provided by a simple extension. */
@JsonDeserialize(as = ImmutableSimpleExtension.ExtensionSignatures.class)
@JsonSerialize(as = ImmutableSimpleExtension.ExtensionSignatures.class)
@@ -1075,6 +1177,14 @@ public abstract static class ExtensionSignatures {
@JsonProperty("types")
public abstract List types();
+ /**
+ * Returns the type variations.
+ *
+ * @return the type variations
+ */
+ @JsonProperty("type_variations")
+ public abstract List typeVariations();
+
/**
* Returns the urn.
*
@@ -1170,6 +1280,14 @@ public abstract static class ExtensionCollection {
types().stream()
.collect(
Collectors.toMap(Type::getAnchor, java.util.function.Function.identity())));
+
+ private final Supplier