kosiew commented on code in PR #24029:
URL: https://github.com/apache/datafusion/pull/24029#discussion_r3713228524


##########
datafusion/functions-aggregate/src/array_agg.rs:
##########
@@ -1781,6 +1785,65 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn ordered_aggregate_nested_nullability_mismatch_issue_24022() -> 
Result<()> {

Review Comment:
   Thanks for adding the ordered aggregate regression. Could you also add 
equivalent coverage for `DistinctArrayAggAccumulator::evaluate`?
   
   Please use a declared struct type with a nullable field and runtime values 
whose struct field is non-nullable, then assert both the exact resulting list 
type and the values. This is the remaining blocking item because the DISTINCT 
decoding path can preserve different nested nullability.



##########
datafusion/common/src/scalar/mod.rs:
##########
@@ -11544,4 +11547,28 @@ mod tests {
         run_tests::<Decimal128Type>();
         run_tests::<Decimal256Type>();
     }
+
+    #[test]
+    fn test_new_list_nested_nullability_mismatch_issue_24022() {
+        // requested element type: Struct(n: Int32 nullable=true)
+        let requested_element_type =
+            DataType::Struct(Fields::from(vec![Field::new("n", 
DataType::Int32, true)]));
+
+        // inferred from concrete values: Struct(n: Int32 nullable=false)
+        let inferred_field = Field::new("n", DataType::Int32, false);
+
+        let value = ScalarValue::Struct(Arc::new(StructArray::from(vec![(
+            Arc::new(inferred_field),
+            Arc::new(Int32Array::from(vec![1])) as ArrayRef,
+        )])));
+
+        let list = ScalarValue::new_list(&[value], &requested_element_type, 
true);

Review Comment:
   Could we extend this regression to cover all three constructors changed by 
this PR?
   
   Right now it only calls `new_list` and checks `list.data_type()`. A shared 
assertion for `new_list`, `new_list_from_iter`, and `new_large_list` would also 
let us verify both the declared nested child type and the normalized child 
values.
   
   This is a suggestion only and does not need to block the PR.



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