Skip to content

Commit a296c41

Browse files
committed
fix
1 parent 32726c9 commit a296c41

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
@@ -236,7 +236,7 @@ private static Type toParquetType(
236236
} else if (dataType instanceof StructType) {
237237
type = toParquetStructType((StructType) dataType, name, repetition);
238238
} else if (dataType instanceof VariantType) {
239-
type = toParquetVariantType((VariantType) dataType, name, repetition);
239+
type = toParquetVariantType(name, repetition);
240240
} else {
241241
throw new UnsupportedOperationException(
242242
"Writing given type data to Parquet is not supported: " + dataType);
@@ -298,13 +298,11 @@ private static Type toParquetStructType(StructType structType, String name,
298298
return new GroupType(repetition, name, fields);
299299
}
300300

301-
private static Type toParquetVariantType(VariantType structType, String name,
302-
Repetition repetition) {
303-
List<Type> fields = Arrays.asList(
304-
toParquetType(BinaryType.BINARY, "value", REQUIRED, Optional.empty()),
305-
toParquetType(BinaryType.BINARY, "metadata", REQUIRED, Optional.empty())
306-
);
307-
return new GroupType(repetition, name, fields);
301+
private static Type toParquetVariantType(String name, Repetition repetition) {
302+
return Types.buildGroup(repetition)
303+
.addField(toParquetType(BinaryType.BINARY, "value", REQUIRED, Optional.empty()))
304+
.addField(toParquetType(BinaryType.BINARY, "metadata", REQUIRED, Optional.empty()))
305+
.named(name);
308306
}
309307

310308
/**

0 commit comments

Comments
 (0)