kumarUjjawal commented on code in PR #20032:
URL: https://github.com/apache/datafusion/pull/20032#discussion_r2740705838
##########
datafusion/functions/src/string/ltrim.rs:
##########
@@ -119,18 +119,87 @@ impl ScalarUDFImpl for LtrimFunc {
}
fn invoke_with_args(&self, args: ScalarFunctionArgs) ->
Result<ColumnarValue> {
- match args.args[0].data_type() {
+ let return_type = args.return_field.data_type();
+ let number_rows = args.number_rows;
+ let args = args.args;
+
+ // If any argument is a scalar NULL, the output is NULL for all rows
+ if args
+ .iter()
+ .any(|v| matches!(v, ColumnarValue::Scalar(s) if s.is_null()))
+ {
+ if args.iter().any(|v| matches!(v, ColumnarValue::Array(_))) {
+ return Ok(ColumnarValue::Array(arrow::array::new_null_array(
+ return_type,
+ number_rows,
+ )));
+ }
+ return
Ok(ColumnarValue::Scalar(ScalarValue::try_from(return_type)?));
+ }
+
+ // Scalar fast path
+ if args.iter().all(|v| matches!(v, ColumnarValue::Scalar(_))) {
Review Comment:
I did all the possible combination benchmark and the scalar path provides
negligible speedup also the common.rs changes are net negative. We are better
droping of this 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]