harshitsaini17 commented on code in PR #19184:
URL: https://github.com/apache/datafusion/pull/19184#discussion_r2596509483
##########
datafusion/spark/src/function/array/shuffle.rs:
##########
@@ -263,3 +268,53 @@ fn fixed_size_array_shuffle(
Some(nulls.into()),
)?))
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use arrow::datatypes::Field;
+ use datafusion_expr::ReturnFieldArgs;
+
+ #[test]
+ fn test_shuffle_nullability() {
+ let shuffle = SparkShuffle::new();
+
+ // Test with non-nullable array
+ let non_nullable_field = Arc::new(Field::new(
+ "arr",
+ List(Arc::new(Field::new("item", DataType::Int32, true))),
+ false, // not nullable
+ ));
+
+ let result = shuffle
+ .return_field_from_args(ReturnFieldArgs {
+ arg_fields: &[non_nullable_field.clone()],
+ scalar_arguments: &[],
+ })
+ .unwrap();
+
+ // The result should not be nullable (same as input)
+ assert!(!result.is_nullable());
+ assert_eq!(result.data_type(), non_nullable_field.data_type());
+
+ // Test with nullable array
+ let nullable_field = Arc::new(Field::new(
+ "arr",
+ List(Arc::new(Field::new("item", DataType::Int32, true))),
+ true, // nullable
+ ));
+
+ let result = shuffle
+ .return_field_from_args(ReturnFieldArgs {
+ arg_fields: &[nullable_field.clone()],
+ scalar_arguments: &[],
+ })
+ .unwrap();
+
+ // The result should be nullable (same as input)
+ assert!(result.is_nullable());
+ assert_eq!(result.data_type(), nullable_field.data_type());
+ }
+}
+
+
Review Comment:
addressed
--
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]