Jefffrey commented on code in PR #22980:
URL: https://github.com/apache/datafusion/pull/22980#discussion_r3635764284
##########
datafusion/common/src/nested_struct.rs:
##########
@@ -264,6 +264,95 @@ 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 = source_col.as_fixed_size_list();
+
+ let source_values = source_list.values();
+ let target_type = target_inner_field.data_type();
+
+ let cast_values = match cast_column(source_values, target_type,
cast_options) {
+ Ok(cast_values) => cast_values,
+ Err(error) => match cast_fixed_size_list_values_with_parent_nulls(
+ source_values,
+ target_type,
+ cast_options,
+ source_list.nulls(),
+ target_list_size,
+ target_inner_field.name(),
+ ) {
+ Some(masked_cast) => masked_cast?,
+ None => return Err(error),
+ },
+ };
+
+ Ok(Arc::new(FixedSizeListArray::new(
+ Arc::clone(target_inner_field),
+ target_list_size,
+ cast_values,
+ source_list.nulls().cloned(),
+ )))
+}
+
+fn cast_fixed_size_list_values_with_parent_nulls(
+ source_values: &ArrayRef,
+ target_type: &DataType,
+ cast_options: &CastOptions,
+ parent_nulls: Option<&NullBuffer>,
+ list_size: i32,
+ field_name: &str,
+) -> Option<Result<ArrayRef>> {
+ let parent_nulls = parent_nulls.filter(|nulls| nulls.null_count() > 0)?;
+
+ // FixedSizeList stores child slots for null parent lists. Those child
+ // values are semantically hidden, but recursive casts still inspect them.
+ // Before masking and retrying, guard schema compatibility so the retry
only
+ // handles value-level failures in hidden child slots and cannot make
runtime
+ // accept schemas that planning rejects.
+ if let Err(error) = validate_data_type_compatibility(
Review Comment:
i still dont agree with having this validate call on the cast path
we dont do anything similar for other list types even though they could
technically contain invalid data (that cant be casted) in a non-empty null slot
--
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]