davidlghellin commented on code in PR #22959:
URL: https://github.com/apache/datafusion/pull/22959#discussion_r3416528442
##########
datafusion/spark/src/function/string/concat_ws.rs:
##########
@@ -123,6 +124,30 @@ impl ScalarUDFImpl for SparkConcatWs {
spark_concat_ws(&args.args, args.number_rows)
}
+
+ fn simplify(
+ &self,
+ args: Vec<Expr>,
+ _info: &SimplifyContext,
+ ) -> Result<ExprSimplifyResult> {
+ if let Some(Expr::Literal(scalar, _)) = args.first()
+ && scalar.is_null()
+ {
+ return Ok(ExprSimplifyResult::Simplified(Expr::Literal(
+ ScalarValue::Utf8(None),
+ None,
+ )));
+ }
+
+ if matches!(args.as_slice(), [Expr::Literal(_, _)]) {
+ return Ok(ExprSimplifyResult::Simplified(Expr::Literal(
+ ScalarValue::Utf8(Some(String::new())),
+ None,
+ )));
+ }
Review Comment:
The second arg to `Expr::Literal` is `Option<FieldMetadata>`, not
`Option<DataType>`. The type is already encoded in the `ScalarValue` variant
(`ScalarValue::Utf8(None)` IS a typed Utf8 NULL). `None` for metadata is the
standard pattern across `datafusion-functions`.
--
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]