diff --git a/kernel/kernel-api/src/main/java/io/delta/kernel/internal/types/DataTypeJsonSerDe.java b/kernel/kernel-api/src/main/java/io/delta/kernel/internal/types/DataTypeJsonSerDe.java index a56b68b78e..58a1fb59c2 100644 --- a/kernel/kernel-api/src/main/java/io/delta/kernel/internal/types/DataTypeJsonSerDe.java +++ b/kernel/kernel-api/src/main/java/io/delta/kernel/internal/types/DataTypeJsonSerDe.java @@ -92,8 +92,8 @@ public static StructType deserializeStructType(String structTypeJson) { DataType parsedType = parseDataType( OBJECT_MAPPER.reader().readTree(structTypeJson), - "" /* fieldPath */, - new FieldMetadata.Builder().build() /* collationsMetadata */); + "" /* fieldPath */, + new FieldMetadata.Builder().build() /* collationsMetadata */); if (parsedType instanceof StructType) { return (StructType) parsedType; } else { @@ -160,20 +160,18 @@ public static StructType deserializeStructType(String structTypeJson) { * } * * - * @param fieldPath Path from the nearest ancestor that is of the {@link StructField} type. - * For example, "c1.key.element" represents a path starting from the {@link StructField} named "c1." - * The next element, "key," indicates that "c1" stores a {@link MapType} type. The final element, "element", - * shows that the key of the map is an {@link ArrayType} type. + * @param fieldPath Path from the nearest ancestor that is of the {@link StructField} type. For + * example, "c1.key.element" represents a path starting from the {@link StructField} named + * "c1." The next element, "key," indicates that "c1" stores a {@link MapType} type. The final + * element, "element", shows that the key of the map is an {@link ArrayType} type. * @param collationsMetadata Metadata that maps the path of a {@link StringType} to its collation. - * Only maps non-UTF8_BINARY collated {@link StringType}. - * Collation metadata is stored in the nearest ancestor, which is the StructField. - * This is because StructField includes a metadata field, whereas Map and Array do not, - * making them unable to store this information. - * Paths are in same form as `fieldPath`. - * Docs + * Only maps non-UTF8_BINARY collated {@link StringType}. Collation metadata is stored in the + * nearest ancestor, which is the StructField. This is because StructField includes a metadata + * field, whereas Map and Array do not, making them unable to store this information. Paths + * are in same form as `fieldPath`. Docs */ - static DataType parseDataType( - JsonNode json, String fieldPath, FieldMetadata collationsMetadata) { + static DataType parseDataType(JsonNode json, String fieldPath, FieldMetadata collationsMetadata) { switch (json.getNodeType()) { case STRING: // simple types are stored as just a string @@ -211,7 +209,8 @@ private static ArrayType parseArrayType( String.format("Expected JSON object with 3 fields for array data type but got:\n%s", json)); boolean containsNull = getBooleanField(json, "containsNull"); DataType dataType = - parseDataType(getNonNullField(json, "elementType"), fieldPath + ".element", collationsMetadata); + parseDataType( + getNonNullField(json, "elementType"), fieldPath + ".element", collationsMetadata); return new ArrayType(dataType, containsNull); } @@ -262,7 +261,8 @@ private static StructField parseStructField(JsonNode json) { String name = getStringField(json, "name"); FieldMetadata metadata = parseFieldMetadata(json.get("metadata"), false); DataType type = - parseDataType(getNonNullField(json, "type"), name, getCollationsMetadata(json.get("metadata"))); + parseDataType( + getNonNullField(json, "type"), name, getCollationsMetadata(json.get("metadata"))); boolean nullable = getBooleanField(json, "nullable"); return new StructField(name, type, nullable, metadata); } @@ -276,7 +276,8 @@ private static FieldMetadata parseFieldMetadata(JsonNode json) { * Parses a {@link FieldMetadata}, optionally including collation metadata, depending on * `includecollationsMetadata`. */ - private static FieldMetadata parseFieldMetadata(JsonNode json, boolean includecollationsMetadata) { + private static FieldMetadata parseFieldMetadata( + JsonNode json, boolean includecollationsMetadata) { if (json == null || json.isNull()) { return FieldMetadata.empty(); } @@ -411,13 +412,12 @@ private static String getStringField(JsonNode rootNode, String fieldName) { private static void assertValidTypeForCollations( String fieldPath, String fieldType, FieldMetadata collationsMetadata) { if (collationsMetadata.contains(fieldPath) && !fieldType.equals("string")) { - throw new IllegalArgumentException(String.format("Invalid data type for collations: \"%s\"", fieldType)); + throw new IllegalArgumentException( + String.format("Invalid data type for collations: \"%s\"", fieldType)); } } - /** - * Returns a metadata with a map of field path to collation name. - */ + /** Returns a metadata with a map of field path to collation name. */ private static FieldMetadata getCollationsMetadata(JsonNode fieldMetadata) { if (fieldMetadata == null || !fieldMetadata.has(DataType.COLLATIONS_METADATA_KEY)) { return new FieldMetadata.Builder().build(); diff --git a/kernel/kernel-api/src/main/java/io/delta/kernel/types/CollationIdentifier.java b/kernel/kernel-api/src/main/java/io/delta/kernel/types/CollationIdentifier.java index 0b8ffae7d7..104878d697 100644 --- a/kernel/kernel-api/src/main/java/io/delta/kernel/types/CollationIdentifier.java +++ b/kernel/kernel-api/src/main/java/io/delta/kernel/types/CollationIdentifier.java @@ -15,17 +15,16 @@ */ package io.delta.kernel.types; -import io.delta.kernel.annotation.Evolving; +import static io.delta.kernel.internal.util.Preconditions.checkArgument; +import io.delta.kernel.annotation.Evolving; import java.util.Objects; import java.util.Optional; -import static io.delta.kernel.internal.util.Preconditions.checkArgument; - /** - * Identifies collation for string type. - * - * Collation identifiers + * Identifies collation for string type. + * Collation identifiers * * @since 3.3.0 */ @@ -55,33 +54,24 @@ public CollationIdentifier(String provider, String collationName, Optional getVersion() { return version; } /** - * - * @param identifier collation identifier in string form of
{@code PROVIDER.COLLATION_NAME[.PROVIDER_VERSION]}. + * @param identifier collation identifier in string form of
+ * {@code PROVIDER.COLLATION_NAME[.PROVIDER_VERSION]}. * @return appropriate collation identifier object */ public static CollationIdentifier fromString(String identifier) { @@ -96,9 +86,7 @@ public static CollationIdentifier fromString(String identifier) { } } - /** - * Collation identifiers are identical when the provider, name, and version are the same. - */ + /** Collation identifiers are identical when the provider, name, and version are the same. */ @Override public boolean equals(Object o) { if (!(o instanceof CollationIdentifier)) { @@ -107,22 +95,16 @@ public boolean equals(Object o) { CollationIdentifier other = (CollationIdentifier) o; return this.provider.equals(other.provider) - && this.name.equals(other.name) - && this.version.equals(other.version); + && this.name.equals(other.name) + && this.version.equals(other.version); } - /** - * - * @return collation identifier in form of {@code PROVIDER.COLLATION_NAME}. - */ + /** @return collation identifier in form of {@code PROVIDER.COLLATION_NAME}. */ public String toStringWithoutVersion() { return String.format("%s.%s", provider, name); } - /** - * - * @return collation identifier in form of {@code PROVIDER.COLLATION_NAME[.PROVIDER_VERSION]} - */ + /** @return collation identifier in form of {@code PROVIDER.COLLATION_NAME[.PROVIDER_VERSION]} */ @Override public String toString() { if (version.isPresent()) { @@ -132,4 +114,3 @@ public String toString() { } } } - diff --git a/kernel/kernel-api/src/main/java/io/delta/kernel/types/StringType.java b/kernel/kernel-api/src/main/java/io/delta/kernel/types/StringType.java index fdb5353d9c..a9ce78e66a 100644 --- a/kernel/kernel-api/src/main/java/io/delta/kernel/types/StringType.java +++ b/kernel/kernel-api/src/main/java/io/delta/kernel/types/StringType.java @@ -30,7 +30,6 @@ public class StringType extends BasePrimitiveType { private final CollationIdentifier collationIdentifier; /** - * * @param collationIdentifier identifier of collation in which this StringType will be observed */ public StringType(CollationIdentifier collationIdentifier) { @@ -39,19 +38,15 @@ public StringType(CollationIdentifier collationIdentifier) { } /** - * - * @param collationName name of collation in which this StringType will be observed. - * In form of {@code PROVIDER.COLLATION_NAME[.VERSION]} + * @param collationName name of collation in which this StringType will be observed. In form of + * {@code PROVIDER.COLLATION_NAME[.VERSION]} */ public StringType(String collationName) { super("string"); this.collationIdentifier = CollationIdentifier.fromString(collationName); } - /** - * - * @return StringType's collation identifier - */ + /** @return StringType's collation identifier */ public CollationIdentifier getCollationIdentifier() { return collationIdentifier; }