Skip to content

Commit fee5be7

Browse files
committed
fix
1 parent 9a0bc09 commit fee5be7

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
@@ -243,7 +243,7 @@ private static Type toParquetType(
243243
} else if (dataType instanceof StructType) {
244244
type = toParquetStructType((StructType) dataType, name, repetition);
245245
} else if (dataType instanceof VariantType) {
246-
type = toParquetVariantType((VariantType) dataType, name, repetition);
246+
type = toParquetVariantType(name, repetition);
247247
} else {
248248
throw new UnsupportedOperationException(
249249
"Writing given type data to Parquet is not supported: " + dataType);
@@ -305,13 +305,11 @@ private static Type toParquetStructType(StructType structType, String name,
305305
return new GroupType(repetition, name, fields);
306306
}
307307

308-
private static Type toParquetVariantType(VariantType structType, String name,
309-
Repetition repetition) {
310-
List<Type> fields = Arrays.asList(
311-
toParquetType(BinaryType.BINARY, "value", REQUIRED, Optional.empty()),
312-
toParquetType(BinaryType.BINARY, "metadata", REQUIRED, Optional.empty())
313-
);
314-
return new GroupType(repetition, name, fields);
308+
private static Type toParquetVariantType(String name, Repetition repetition) {
309+
return Types.buildGroup(repetition)
310+
.addField(toParquetType(BinaryType.BINARY, "value", REQUIRED, Optional.empty()))
311+
.addField(toParquetType(BinaryType.BINARY, "metadata", REQUIRED, Optional.empty()))
312+
.named(name);
315313
}
316314

317315
/**

0 commit comments

Comments
 (0)