Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
abb4783
Site: Learn More to point to Spark QuickStart Doc (#12272)
danicafine Feb 14, 2025
71493b9
Build: Bump datamodel-code-generator from 0.27.2 to 0.28.1 (#12290)
manuzhang Feb 16, 2025
0bc2d70
Spark 3.5: Fix job description of RewriteTablePathSparkAction (#12282)
ebyhr Feb 17, 2025
aed04d0
Build: Bump io.netty:netty-buffer from 4.1.117.Final to 4.1.118.Final…
dependabot[bot] Feb 17, 2025
aec763a
Build: Bump software.amazon.awssdk:bom from 2.30.16 to 2.30.21 (#12286)
dependabot[bot] Feb 17, 2025
f9b9621
OpenAPI: Add overwrite option when registering a table (#12239)
dramaticlly Feb 17, 2025
bcbbd03
Build: Bump mkdocs-material from 9.6.3 to 9.6.4 (#12284)
dependabot[bot] Feb 17, 2025
e8d3a06
Core: Fix Enabling row-lineage during Create Table (#12307)
tomtongue Feb 18, 2025
93ef861
API: Reject unknown type for required fields and validate defaults (#…
rdblue Feb 18, 2025
b62fb42
API: Fix TestInclusiveMetricsEvaluator notStartsWith tests. (#12303)
rdblue Feb 18, 2025
0b47faa
Core: Add variant type support to utils and visitors (#11831)
aihuaxu Feb 18, 2025
e79295b
Core: Fix CI: Update tests with UnknownType from required to optional…
Fokko Feb 18, 2025
5e1ce86
Docs: Refactor site navigation bar (#12289)
manuzhang Feb 18, 2025
3c8f369
Parquet: Implement Variant readers (#12139)
rdblue Feb 18, 2025
7e4f0ca
Docs: Add rewrite_table_path Spark Procedure (#12115)
dramaticlly Feb 19, 2025
ea4393e
Parquet: Fix errorprone warning (#12324)
ebyhr Feb 19, 2025
1bf55b4
Docs: Add Apache Amoro docs (#11966)
czy006 Feb 19, 2025
c1d4182
Parquet: Fix performance regression in reader init (#12305)
bryanck Feb 19, 2025
387d258
Core: Fallback to GET requests for namespace/table/view exists checks…
nastra Feb 19, 2025
2e6e38c
Docs: Fix refs in Apache Amoro docs (#12332)
czy006 Feb 19, 2025
3a23f85
Revert "Core: Serialize `null` when there is no current snapshot (#11…
Fokko Feb 19, 2025
686bae5
Parquet: Fix performance regression in reader init (#12305) (#12329)
nastra Feb 19, 2025
fad0c1e
Checkstyle: Apply the same generic type naming rules to interfaces an…
pvary Feb 19, 2025
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
3 changes: 3 additions & 0 deletions .baseline/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@
<module name="ClassTypeParameterName"> <!-- Java Style Guide: Type variable names -->
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
</module>
<module name="InterfaceTypeParameterName"> <!-- Java Style Guide: Type variable names -->
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
</module>
<module name="CovariantEquals"/> <!-- Java Coding Guidelines: Override ``Object#equals`` consistently -->
<module name="DefaultComesLast"/> <!-- Java Style Guide: The default case is present -->
<module name="EmptyBlock"> <!-- Java Style Guide: Empty blocks: documented -->
Expand Down
5 changes: 5 additions & 0 deletions api/src/main/java/org/apache/iceberg/Accessors.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ public Map<Integer, Accessor<StructLike>> struct(
return accessors;
}

@Override
public Map<Integer, Accessor<StructLike>> variant(Types.VariantType variant) {
return null;
}

@Override
public Map<Integer, Accessor<StructLike>> field(
Types.NestedField field, Map<Integer, Accessor<StructLike>> fieldResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public Type map(Types.MapType map, Supplier<Type> keyFuture, Supplier<Type> valu
}
}

@Override
public Type variant(Types.VariantType variant) {
return variant;
}

@Override
public Type primitive(Type.PrimitiveType primitive) {
return primitive;
Expand Down
5 changes: 5 additions & 0 deletions api/src/main/java/org/apache/iceberg/types/AssignIds.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public Type map(Types.MapType map, Supplier<Type> keyFuture, Supplier<Type> valu
}
}

@Override
public Type variant(Types.VariantType variant) {
return variant;
}

@Override
public Type primitive(Type.PrimitiveType primitive) {
return primitive;
Expand Down
10 changes: 10 additions & 0 deletions api/src/main/java/org/apache/iceberg/types/CheckCompatibility.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,16 @@ public List<String> map(
}
}

@Override
public List<String> variant(Types.VariantType readVariant) {
if (currentType.isVariantType()) {
return NO_ERRORS;
}

// Currently promotion is not allowed to variant type
return ImmutableList.of(String.format(": %s cannot be read as a %s", currentType, readVariant));
}

@Override
public List<String> primitive(Type.PrimitiveType readPrimitive) {
if (currentType.equals(readPrimitive)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public Type map(Types.MapType map, Type keyResult, Type valueResult) {
}

@Override
public Type variant() {
if (predicate.test(Types.VariantType.get())) {
return Types.VariantType.get();
public Type variant(Types.VariantType variant) {
if (predicate.test(variant)) {
return variant;
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public Set<Integer> struct(Types.StructType struct, List<Set<Integer>> fieldResu

@Override
public Set<Integer> field(Types.NestedField field, Set<Integer> fieldResult) {
if ((includeStructIds && field.type().isStructType()) || field.type().isPrimitiveType()) {
if ((includeStructIds && field.type().isStructType())
|| field.type().isPrimitiveType()
|| field.type().isVariantType()) {
fieldIds.add(field.fieldId());
}
return fieldIds;
Expand All @@ -72,4 +74,9 @@ public Set<Integer> map(Types.MapType map, Set<Integer> keyResult, Set<Integer>
}
return fieldIds;
}

@Override
public Set<Integer> variant(Types.VariantType variant) {
return null;
}
}
5 changes: 5 additions & 0 deletions api/src/main/java/org/apache/iceberg/types/IndexById.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,9 @@ public Map<Integer, Types.NestedField> map(
}
return null;
}

@Override
public Map<Integer, Types.NestedField> variant(Types.VariantType variant) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public Map<String, Integer> map(
}

@Override
public Map<String, Integer> variant() {
public Map<String, Integer> variant(Types.VariantType variant) {
return nameToId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Map<Integer, Integer> map(
}

@Override
public Map<Integer, Integer> variant() {
public Map<Integer, Integer> variant(Types.VariantType variant) {
return idToParent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ class PrimitiveHolder implements Serializable {
}

Object readResolve() throws ObjectStreamException {
return Types.fromPrimitiveString(typeAsString);
return Types.fromTypeName(typeAsString);
}
}
5 changes: 5 additions & 0 deletions api/src/main/java/org/apache/iceberg/types/PruneColumns.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ public Type map(Types.MapType map, Type ignored, Type valueResult) {
return null;
}

@Override
public Type variant(Types.VariantType variant) {
return null;
}

@Override
public Type primitive(Type.PrimitiveType primitive) {
return null;
Expand Down
5 changes: 5 additions & 0 deletions api/src/main/java/org/apache/iceberg/types/ReassignDoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public Type map(Types.MapType map, Supplier<Type> keyTypeFuture, Supplier<Type>
}
}

@Override
public Type variant(Types.VariantType variant) {
return variant;
}

@Override
public Type primitive(Type.PrimitiveType primitive) {
return primitive;
Expand Down
5 changes: 5 additions & 0 deletions api/src/main/java/org/apache/iceberg/types/ReassignIds.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ public Type map(Types.MapType map, Supplier<Type> keyTypeFuture, Supplier<Type>
}
}

@Override
public Type variant(Types.VariantType variant) {
return variant;
}

@Override
public Type primitive(Type.PrimitiveType primitive) {
return primitive; // nothing to reassign
Expand Down
8 changes: 8 additions & 0 deletions api/src/main/java/org/apache/iceberg/types/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ default Types.MapType asMapType() {
throw new IllegalArgumentException("Not a map type: " + this);
}

default Types.VariantType asVariantType() {
throw new IllegalArgumentException("Not a variant type: " + this);
}

default boolean isNestedType() {
return false;
}
Expand All @@ -98,6 +102,10 @@ default boolean isMapType() {
return false;
}

default boolean isVariantType() {
return false;
}

default NestedType asNestedType() {
throw new IllegalArgumentException("Not a nested type: " + this);
}
Expand Down
19 changes: 17 additions & 2 deletions api/src/main/java/org/apache/iceberg/types/TypeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,16 @@ public T map(Types.MapType map, T keyResult, T valueResult) {
return null;
}

/**
* @deprecated will be removed in 2.0.0; use {@link #variant(Types.VariantType)} instead.
*/
@Deprecated
public T variant() {
return null;
return variant(Types.VariantType.get());
}

public T variant(Types.VariantType variant) {
throw new UnsupportedOperationException("Unsupported type: variant");
}

public T primitive(Type.PrimitiveType primitive) {
Expand Down Expand Up @@ -684,7 +692,7 @@ public static <T> T visit(Type type, SchemaVisitor<T> visitor) {
return visitor.map(map, keyResult, valueResult);

case VARIANT:
return visitor.variant();
return visitor.variant(type.asVariantType());

default:
return visitor.primitive(type.asPrimitiveType());
Expand Down Expand Up @@ -712,6 +720,10 @@ public T map(Types.MapType map, Supplier<T> keyResult, Supplier<T> valueResult)
return null;
}

public T variant(Types.VariantType variant) {
throw new UnsupportedOperationException("Unsupported type: variant");
}

public T primitive(Type.PrimitiveType primitive) {
return null;
}
Expand Down Expand Up @@ -788,6 +800,9 @@ public static <T> T visit(Type type, CustomOrderSchemaVisitor<T> visitor) {
new VisitFuture<>(map.keyType(), visitor),
new VisitFuture<>(map.valueType(), visitor));

case VARIANT:
return visitor.variant(type.asVariantType());

default:
return visitor.primitive(type.asPrimitiveType());
}
Expand Down
35 changes: 31 additions & 4 deletions api/src/main/java/org/apache/iceberg/types/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public class Types {

private Types() {}

private static final ImmutableMap<String, PrimitiveType> TYPES =
ImmutableMap.<String, PrimitiveType>builder()
private static final ImmutableMap<String, Type> TYPES =
ImmutableMap.<String, Type>builder()
.put(BooleanType.get().toString(), BooleanType.get())
.put(IntegerType.get().toString(), IntegerType.get())
.put(LongType.get().toString(), LongType.get())
Expand All @@ -57,13 +57,14 @@ private Types() {}
.put(UUIDType.get().toString(), UUIDType.get())
.put(BinaryType.get().toString(), BinaryType.get())
.put(UnknownType.get().toString(), UnknownType.get())
.put(VariantType.get().toString(), VariantType.get())
.buildOrThrow();

private static final Pattern FIXED = Pattern.compile("fixed\\[\\s*(\\d+)\\s*\\]");
private static final Pattern DECIMAL =
Pattern.compile("decimal\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)");

public static PrimitiveType fromPrimitiveString(String typeString) {
public static Type fromTypeName(String typeString) {
String lowerTypeString = typeString.toLowerCase(Locale.ROOT);
if (TYPES.containsKey(lowerTypeString)) {
return TYPES.get(lowerTypeString);
Expand All @@ -82,6 +83,15 @@ public static PrimitiveType fromPrimitiveString(String typeString) {
throw new IllegalArgumentException("Cannot parse type string to primitive: " + typeString);
}

public static PrimitiveType fromPrimitiveString(String typeString) {
Type type = fromTypeName(typeString);
if (type.isPrimitiveType()) {
return type.asPrimitiveType();
}

throw new IllegalArgumentException("Cannot parse type string: variant is not a primitive type");
}

public static class BooleanType extends PrimitiveType {
private static final BooleanType INSTANCE = new BooleanType();

Expand Down Expand Up @@ -431,6 +441,16 @@ public String toString() {
return "variant";
}

@Override
public boolean isVariantType() {
return true;
}

@Override
public VariantType asVariantType() {
return this;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down Expand Up @@ -692,6 +712,10 @@ private NestedField(
Literal<?> writeDefault) {
Preconditions.checkNotNull(name, "Name cannot be null");
Preconditions.checkNotNull(type, "Type cannot be null");
Preconditions.checkArgument(
isOptional || !type.equals(UnknownType.get()),
"Cannot create required field with unknown type: %s",
name);
this.isOptional = isOptional;
this.id = id;
this.name = name;
Expand All @@ -706,7 +730,10 @@ private static Literal<?> castDefault(Literal<?> defaultValue, Type type) {
throw new IllegalArgumentException(
String.format("Invalid default value for %s: %s (must be null)", type, defaultValue));
} else if (defaultValue != null) {
return defaultValue.to(type);
Literal<?> typedDefault = defaultValue.to(type);
Preconditions.checkArgument(
typedDefault != null, "Cannot cast default value to %s: %s", type, defaultValue);
return typedDefault;
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class TestPartitionSpecValidation {
NestedField.required(5, "another_d", Types.TimestampType.withZone()),
NestedField.required(6, "s", Types.StringType.get()),
NestedField.required(7, "v", Types.VariantType.get()),
NestedField.required(8, "u", Types.UnknownType.get()));
NestedField.optional(8, "u", Types.UnknownType.get()));

@Test
public void testMultipleTimestampPartitions() {
Expand Down
Loading