@@ -249,7 +249,7 @@ private static Type toParquetType(
249
249
} else if (dataType instanceof StructType ) {
250
250
type = toParquetStructType ((StructType ) dataType , name , repetition );
251
251
} else if (dataType instanceof VariantType ) {
252
- type = toParquetVariantType (( VariantType ) dataType , name , repetition );
252
+ type = toParquetVariantType (name , repetition );
253
253
} else {
254
254
throw new UnsupportedOperationException (
255
255
"Writing given type data to Parquet is not supported: " + dataType );
@@ -311,13 +311,11 @@ private static Type toParquetStructType(StructType structType, String name,
311
311
return new GroupType (repetition , name , fields );
312
312
}
313
313
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 );
321
319
}
322
320
323
321
/**
0 commit comments