File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
main/java/org/apache/parquet/arrow/schema
test/java/org/apache/parquet/arrow/schema Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -498,7 +498,17 @@ public TypeMapping convertINT96(PrimitiveTypeName primitiveTypeName) throws Runt
498498
499499 @ Override
500500 public TypeMapping convertFIXED_LEN_BYTE_ARRAY (PrimitiveTypeName primitiveTypeName ) throws RuntimeException {
501- return field (new ArrowType .Binary ());
501+ LogicalTypeAnnotation logicalTypeAnnotation = type .getLogicalTypeAnnotation ();
502+ if (logicalTypeAnnotation == null ) {
503+ return field (new ArrowType .Binary ());
504+ }
505+
506+ return logicalTypeAnnotation .accept (new LogicalTypeAnnotation .LogicalTypeAnnotationVisitor <TypeMapping >() {
507+ @ Override
508+ public Optional <TypeMapping > visit (LogicalTypeAnnotation .DecimalLogicalTypeAnnotation decimalLogicalType ) {
509+ return of (decimal (decimalLogicalType .getPrecision (), decimalLogicalType .getScale ()));
510+ }
511+ }).orElseThrow (() -> new IllegalArgumentException ("illegal type " + type ));
502512 }
503513
504514 @ Override
Original file line number Diff line number Diff line change @@ -419,6 +419,26 @@ public void testParquetInt64TimeMicrosToArrow() {
419419 Assert .assertEquals (expected , converter .fromParquet (parquet ).getArrowSchema ());
420420 }
421421
422+ @ Test
423+ public void testParquetFixedBinaryToArrow () {
424+ MessageType parquet = Types .buildMessage ()
425+ .addField (Types .optional (FIXED_LEN_BYTE_ARRAY ).length (12 ).named ("a" )).named ("root" );
426+ Schema expected = new Schema (asList (
427+ field ("a" , new ArrowType .Binary ())
428+ ));
429+ Assert .assertEquals (expected , converter .fromParquet (parquet ).getArrowSchema ());
430+ }
431+
432+ @ Test
433+ public void testParquetFixedBinaryToArrowDecimal () {
434+ MessageType parquet = Types .buildMessage ()
435+ .addField (Types .optional (FIXED_LEN_BYTE_ARRAY ).length (5 ).as (DECIMAL ).precision (8 ).scale (2 ).named ("a" )).named ("root" );
436+ Schema expected = new Schema (asList (
437+ field ("a" , new ArrowType .Decimal (8 , 2 ))
438+ ));
439+ Assert .assertEquals (expected , converter .fromParquet (parquet ).getArrowSchema ());
440+ }
441+
422442 @ Test (expected = IllegalStateException .class )
423443 public void testParquetInt64TimeMillisToArrow () {
424444 converter .fromParquet (Types .buildMessage ()
You can’t perform that action at this time.
0 commit comments