@@ -357,7 +357,13 @@ impl<'a> PrimitiveTypeBuilder<'a> {
357
357
( LogicalType :: String , PhysicalType :: BYTE_ARRAY ) => { }
358
358
( LogicalType :: Json , PhysicalType :: BYTE_ARRAY ) => { }
359
359
( LogicalType :: Bson , PhysicalType :: BYTE_ARRAY ) => { }
360
- ( LogicalType :: Uuid , PhysicalType :: FIXED_LEN_BYTE_ARRAY ) => { }
360
+ ( LogicalType :: Uuid , PhysicalType :: FIXED_LEN_BYTE_ARRAY ) if self . length == 16 => { }
361
+ ( LogicalType :: Uuid , PhysicalType :: FIXED_LEN_BYTE_ARRAY ) => {
362
+ return Err ( general_err ! (
363
+ "UUID cannot annotate field '{}' because it is not a FIXED_LEN_BYTE_ARRAY(16) field" ,
364
+ self . name
365
+ ) )
366
+ }
361
367
( LogicalType :: Float16 , PhysicalType :: FIXED_LEN_BYTE_ARRAY )
362
368
if self . length == 2 => { }
363
369
( LogicalType :: Float16 , PhysicalType :: FIXED_LEN_BYTE_ARRAY ) => {
@@ -1594,6 +1600,20 @@ mod tests {
1594
1600
"Parquet error: FLOAT16 cannot annotate field 'foo' because it is not a FIXED_LEN_BYTE_ARRAY(2) field"
1595
1601
) ;
1596
1602
}
1603
+
1604
+ // Must have length 16
1605
+ result = Type :: primitive_type_builder ( "foo" , PhysicalType :: FIXED_LEN_BYTE_ARRAY )
1606
+ . with_repetition ( Repetition :: REQUIRED )
1607
+ . with_logical_type ( Some ( LogicalType :: Uuid ) )
1608
+ . with_length ( 15 )
1609
+ . build ( ) ;
1610
+ assert ! ( result. is_err( ) ) ;
1611
+ if let Err ( e) = result {
1612
+ assert_eq ! (
1613
+ format!( "{e}" ) ,
1614
+ "Parquet error: UUID cannot annotate field 'foo' because it is not a FIXED_LEN_BYTE_ARRAY(16) field"
1615
+ ) ;
1616
+ }
1597
1617
}
1598
1618
1599
1619
#[ test]
0 commit comments