Jefffrey commented on code in PR #22980:
URL: https://github.com/apache/datafusion/pull/22980#discussion_r3425614474


##########
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(

Review Comment:
   The other `cast_*_column` methods don't do this validate call, is this 
significant?



##########
datafusion/common/src/nested_struct.rs:
##########
@@ -208,15 +231,7 @@ fn cast_list_column<O: arrow::array::OffsetSizeTrait>(
     target_inner_field: &FieldRef,
     cast_options: &CastOptions,
 ) -> Result<ArrayRef> {
-    let source_list = source_col
-        .as_any()
-        .downcast_ref::<GenericListArray<O>>()
-        .ok_or_else(|| {
-            crate::error::DataFusionError::Plan(format!(
-                "Expected list array but got {}",
-                source_col.data_type()
-            ))
-        })?;
+    let source_list = downcast_array!(source_col, GenericListArray<O>, "list 
array")?;

Review Comment:
   ```suggestion
       let source_list = source_col.as_list::<O>();
   ```
   
   Can replace this helper with existing downcast methods (here and everywhere 
else)



##########
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:
   I dont understand whats happening here; why do we have this fallback if we 
fail to cast?



-- 
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]

Reply via email to