gbrgr commented on code in PR #1824:
URL: https://github.com/apache/iceberg-rust/pull/1824#discussion_r2601436502
##########
crates/iceberg/src/arrow/record_batch_transformer.rs:
##########
@@ -53,20 +54,59 @@ use crate::{Error, ErrorKind, Result};
fn constants_map(
partition_spec: &PartitionSpec,
partition_data: &Struct,
-) -> HashMap<i32, PrimitiveLiteral> {
+ schema: &IcebergSchema,
+) -> Result<HashMap<i32, Datum>> {
let mut constants = HashMap::new();
for (pos, field) in partition_spec.fields().iter().enumerate() {
// Only identity transforms should use constant values from partition
metadata
if matches!(field.transform, Transform::Identity) {
+ // Get the field from schema to extract its type
+ let iceberg_field =
schema.field_by_id(field.source_id).ok_or(Error::new(
+ ErrorKind::Unexpected,
+ format!("Field {} not found in schema", field.source_id),
+ ))?;
+
+ // Ensure the field type is primitive
+ let prim_type = match &*iceberg_field.field_type {
+ crate::spec::Type::Primitive(prim_type) => prim_type,
+ _ => {
+ return Err(Error::new(
+ ErrorKind::Unexpected,
+ format!(
+ "Partition field {} has non-primitive type {:?}",
+ field.source_id, iceberg_field.field_type
+ ),
+ ));
+ }
+ };
+
// Get the partition value for this field
- if let Some(Literal::Primitive(value)) = &partition_data[pos] {
- constants.insert(field.source_id, value.clone());
+ // Handle both None (null) and Some(Literal::Primitive) cases
+ match &partition_data[pos] {
+ None => {
Review Comment:
Issue here: https://github.com/apache/iceberg-rust/issues/1914
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]