kosiew commented on code in PR #22980:
URL: https://github.com/apache/datafusion/pull/22980#discussion_r3433463267
##########
datafusion/common/src/nested_struct.rs:
##########
@@ -264,6 +272,72 @@ fn cast_list_view_column<O: arrow::array::OffsetSizeTrait>(
Ok(Arc::new(result))
}
+fn cast_fixed_size_list_column(
+ source_col: &ArrayRef,
+ target_inner_field: &FieldRef,
+ target_list_size: i32,
+ cast_options: &CastOptions,
+) -> Result<ArrayRef> {
+ let source_list =
+ downcast_array!(source_col, FixedSizeListArray, "fixed-size list
array")?;
+
+ let source_values = source_list.values();
+ let target_type = target_inner_field.data_type();
+
+ validate_data_type_compatibility(
+ target_inner_field.name(),
+ source_values.data_type(),
+ target_type,
+ )?;
+
+ let cast_values = match cast_column(source_values, target_type,
cast_options) {
+ Ok(cast_values) => cast_values,
+ Err(error) => match source_list.nulls() {
+ Some(parent_nulls) if parent_nulls.null_count() > 0 => {
+ let hidden_child_nulls = parent_nulls.expand(target_list_size
as usize);
+ let masked_values =
Review Comment:
The fallback is intentional. `FixedSizeListArray` stores `len * list_size`
child values even for null parent list entries, so recursive casting can fail
on child values that are semantically hidden by a null parent. The fallback
expands the parent null bitmap to child positions, masks those hidden child
values to null, and retries; visible child values are still cast normally.
`test_cast_fixed_size_list_struct_ignores_hidden_child_values_for_null_parent`
covers this case. I’ll add a targeted comment and keep the fallback limited to
this null-parent masking case.
--
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]