This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new c2b05cdbcb3 Check length of `FIXED_LEN_BYTE_ARRAY` for `uuid` logical
parquet type (#5821)
c2b05cdbcb3 is described below
commit c2b05cdbcb37f46f170c7b5073ee6bc2178fdace
Author: Matthijs Brobbel <[email protected]>
AuthorDate: Fri May 31 15:26:20 2024 +0200
Check length of `FIXED_LEN_BYTE_ARRAY` for `uuid` logical parquet type
(#5821)
---
parquet/src/schema/types.rs | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/parquet/src/schema/types.rs b/parquet/src/schema/types.rs
index fbdc0929a5a..13cc016df02 100644
--- a/parquet/src/schema/types.rs
+++ b/parquet/src/schema/types.rs
@@ -357,7 +357,13 @@ impl<'a> PrimitiveTypeBuilder<'a> {
(LogicalType::String, PhysicalType::BYTE_ARRAY) => {}
(LogicalType::Json, PhysicalType::BYTE_ARRAY) => {}
(LogicalType::Bson, PhysicalType::BYTE_ARRAY) => {}
- (LogicalType::Uuid, PhysicalType::FIXED_LEN_BYTE_ARRAY) =>
{}
+ (LogicalType::Uuid, PhysicalType::FIXED_LEN_BYTE_ARRAY) if
self.length == 16 => {}
+ (LogicalType::Uuid, PhysicalType::FIXED_LEN_BYTE_ARRAY) =>
{
+ return Err(general_err!(
+ "UUID cannot annotate field '{}' because it is not
a FIXED_LEN_BYTE_ARRAY(16) field",
+ self.name
+ ))
+ }
(LogicalType::Float16, PhysicalType::FIXED_LEN_BYTE_ARRAY)
if self.length == 2 => {}
(LogicalType::Float16, PhysicalType::FIXED_LEN_BYTE_ARRAY)
=> {
@@ -1594,6 +1600,20 @@ mod tests {
"Parquet error: FLOAT16 cannot annotate field 'foo' because it
is not a FIXED_LEN_BYTE_ARRAY(2) field"
);
}
+
+ // Must have length 16
+ result = Type::primitive_type_builder("foo",
PhysicalType::FIXED_LEN_BYTE_ARRAY)
+ .with_repetition(Repetition::REQUIRED)
+ .with_logical_type(Some(LogicalType::Uuid))
+ .with_length(15)
+ .build();
+ assert!(result.is_err());
+ if let Err(e) = result {
+ assert_eq!(
+ format!("{e}"),
+ "Parquet error: UUID cannot annotate field 'foo' because it is
not a FIXED_LEN_BYTE_ARRAY(16) field"
+ );
+ }
}
#[test]