@@ -236,7 +236,7 @@ private static Type toParquetType(
236
236
} else if (dataType instanceof StructType ) {
237
237
type = toParquetStructType ((StructType ) dataType , name , repetition );
238
238
} else if (dataType instanceof VariantType ) {
239
- type = toParquetVariantType (( VariantType ) dataType , name , repetition );
239
+ type = toParquetVariantType (name , repetition );
240
240
} else {
241
241
throw new UnsupportedOperationException (
242
242
"Writing given type data to Parquet is not supported: " + dataType );
@@ -298,13 +298,11 @@ private static Type toParquetStructType(StructType structType, String name,
298
298
return new GroupType (repetition , name , fields );
299
299
}
300
300
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 );
308
306
}
309
307
310
308
/**
0 commit comments