in crates/iceberg/src/transaction/snapshot.rs [96:124]
fn validate_partition_value(
partition_value: &Struct,
partition_type: &StructType,
) -> Result<()> {
if partition_value.fields().len() != partition_type.fields().len() {
return Err(Error::new(
ErrorKind::DataInvalid,
"Partition value is not compatible with partition type",
));
}
for (value, field) in partition_value.fields().iter().zip(partition_type.fields()) {
let field = field.field_type.as_primitive_type().ok_or_else(|| {
Error::new(
ErrorKind::Unexpected,
"Partition field should only be primitive type.",
)
})?;
if let Some(value) = value {
if !field.compatible(&value.as_primitive_literal().unwrap()) {
return Err(Error::new(
ErrorKind::DataInvalid,
"Partition value is not compatible partition type",
));
}
}
}
Ok(())
}