@@ -243,7 +243,7 @@ private static Type toParquetType(
243
243
} else if (dataType instanceof StructType ) {
244
244
type = toParquetStructType ((StructType ) dataType , name , repetition );
245
245
} else if (dataType instanceof VariantType ) {
246
- type = toParquetVariantType (( VariantType ) dataType , name , repetition );
246
+ type = toParquetVariantType (name , repetition );
247
247
} else {
248
248
throw new UnsupportedOperationException (
249
249
"Writing given type data to Parquet is not supported: " + dataType );
@@ -305,13 +305,11 @@ private static Type toParquetStructType(StructType structType, String name,
305
305
return new GroupType (repetition , name , fields );
306
306
}
307
307
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 );
315
313
}
316
314
317
315
/**
0 commit comments