anoopj commented on code in PR #2985:
URL: https://github.com/apache/iceberg-rust/pull/2985#discussion_r3763829972
##########
crates/iceberg/src/arrow/record_batch_transformer.rs:
##########
@@ -870,11 +930,53 @@ impl RecordBatchTransformer {
fields,
child_values,
} => Self::create_struct_column(fields, child_values,
num_rows)?,
+
+ ColumnSource::Coalesce {
+ source_index,
+ fallback,
+ target_type,
+ } => Self::create_coalesce_column(
+ &columns[*source_index],
+ fallback,
+ target_type,
+ )?,
})
})
.collect()
}
+ /// Builds a coalesced column: the source column's per-row value where
non-null,
+ /// else the scalar `fallback`, cast to `target_type` (the run-end-encoded
type
+ /// the column's other paths produce).
+ fn create_coalesce_column(
+ source: &ArrayRef,
+ fallback: &PrimitiveLiteral,
+ target_type: &DataType,
+ ) -> Result<ArrayRef> {
+ if source.data_type() != &DataType::Int64 {
+ return Err(Error::new(
+ ErrorKind::Unexpected,
+ format!(
+ "coalesce source must be Int64, got {:?}",
+ source.data_type()
+ ),
+ ));
+ }
+ let PrimitiveLiteral::Long(seq) = fallback else {
+ return Err(Error::new(
+ ErrorKind::Unexpected,
+ format!("coalesce fallback must be a long, got {fallback:?}"),
+ ));
+ };
+ let scalar = Int64Array::new_scalar(*seq);
+ let mask = is_not_null(source)?;
Review Comment:
Added both.
--
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]