Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aihuaxu committed Jan 30, 2025
1 parent 75114f1 commit 760ed7d
Show file tree
Hide file tree
Showing 15 changed files with 198 additions and 131 deletions.
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() {
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 @@ -74,4 +74,9 @@ public Set<Integer> map(Types.MapType map, Set<Integer> keyResult, Set<Integer>
}
return fieldIds;
}

@Override
public Set<Integer> 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() {
return null;
}
}
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() {
return null;
}

@Override
public Type primitive(Type.PrimitiveType primitive) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/apache/iceberg/types/TypeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ public T map(Types.MapType map, T keyResult, T valueResult) {
}

public T variant() {
return null;
throw new UnsupportedOperationException("Unsupported type: variant");
}

public T primitive(Type.PrimitiveType primitive) {
Expand Down
15 changes: 4 additions & 11 deletions api/src/main/java/org/apache/iceberg/types/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,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 @@ -56,21 +56,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 Type typeFromTypeString(String typeString) {
if (VariantType.get().toString().equalsIgnoreCase(typeString)) {
return Types.VariantType.get();
}

return Types.fromPrimitiveString(typeString);
}

public static PrimitiveType fromPrimitiveString(String typeString) {
public static Type fromPrimitiveString(String typeString) {
String lowerTypeString = typeString.toLowerCase(Locale.ROOT);
if (TYPES.containsKey(lowerTypeString)) {
return TYPES.get(lowerTypeString);
Expand Down
Loading

0 comments on commit 760ed7d

Please sign in to comment.