rluvaton commented on code in PR #19182:
URL: https://github.com/apache/datafusion/pull/19182#discussion_r2596537530
##########
datafusion/spark/src/function/string/length.rs:
##########
@@ -279,4 +286,38 @@ mod tests {
Ok(())
}
+
+ #[test]
+ fn test_spark_length_nullability() -> Result<()> {
+ let func = SparkLengthFunc::new();
+
+ let nullable_field: FieldRef =
+ Arc::new(Field::new("col", DataType::Utf8, true));
+
+ let out_nullable = func.return_field_from_args(ReturnFieldArgs {
+ arg_fields: &[nullable_field],
+ scalar_arguments: &[],
+ })?;
+
+ assert!(
+ out_nullable.is_nullable(),
+ "length(col) should be nullable when child is nullable"
+ );
+
+ let non_nullable_field: FieldRef =
+ Arc::new(Field::new("col", DataType::Utf8, false));
+
+ let out_non_nullable = func.return_field_from_args(ReturnFieldArgs {
+ arg_fields: &[non_nullable_field],
+ scalar_arguments: &[],
Review Comment:
```suggestion
scalar_arguments: &[None],
```
--
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]