Skip to content

Commit b65e502

Browse files
committed
fix
1 parent b37deff commit b65e502

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

kernel/kernel-defaults/src/main/java/io/delta/kernel/defaults/internal/parquet/ParquetSchemaUtils.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ private static Type toParquetType(
249249
} else if (dataType instanceof StructType) {
250250
type = toParquetStructType((StructType) dataType, name, repetition);
251251
} else if (dataType instanceof VariantType) {
252-
type = toParquetVariantType((VariantType) dataType, name, repetition);
252+
type = toParquetVariantType(name, repetition);
253253
} else {
254254
throw new UnsupportedOperationException(
255255
"Writing given type data to Parquet is not supported: " + dataType);
@@ -311,13 +311,11 @@ private static Type toParquetStructType(StructType structType, String name,
311311
return new GroupType(repetition, name, fields);
312312
}
313313

314-
private static Type toParquetVariantType(VariantType structType, String name,
315-
Repetition repetition) {
316-
List<Type> fields = Arrays.asList(
317-
toParquetType(BinaryType.BINARY, "value", REQUIRED, Optional.empty()),
318-
toParquetType(BinaryType.BINARY, "metadata", REQUIRED, Optional.empty())
319-
);
320-
return new GroupType(repetition, name, fields);
314+
private static Type toParquetVariantType(String name, Repetition repetition) {
315+
return Types.buildGroup(repetition)
316+
.addField(toParquetType(BinaryType.BINARY, "value", REQUIRED, Optional.empty()))
317+
.addField(toParquetType(BinaryType.BINARY, "metadata", REQUIRED, Optional.empty()))
318+
.named(name);
321319
}
322320

323321
/**

0 commit comments

Comments
 (0)