davidlghellin commented on code in PR #22959:
URL: https://github.com/apache/datafusion/pull/22959#discussion_r3416531798
##########
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,
+ )));
+ }
Review Comment:
Empirically not an issue today — the SLT `EXPLAIN SELECT concat_ws(CAST(NULL
AS STRING), a, b) ...` folds to `Projection: Utf8(NULL)`, which means
`ConstEvaluator` collapses the CAST to a typed NULL literal before `simplify()`
runs. If the optimizer pass order ever shifts and the wrapper survives, the SLT
will fail visibly. Happy to add peeling if you have a reproducer where it
doesn't fold today.
--
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]