neilconway commented on code in PR #20657:
URL: https://github.com/apache/datafusion/pull/20657#discussion_r2961254688


##########
datafusion/functions/src/unicode/lpad.rs:
##########
@@ -112,14 +113,64 @@ impl ScalarUDFImpl for LPadFunc {
         utf8_to_str_type(&arg_types[0], "lpad")
     }
 
-    fn invoke_with_args(
-        &self,
-        args: datafusion_expr::ScalarFunctionArgs,
-    ) -> Result<ColumnarValue> {
-        let args = &args.args;
+    fn invoke_with_args(&self, args: ScalarFunctionArgs) -> 
Result<ColumnarValue> {
+        let ScalarFunctionArgs {
+            args, number_rows, ..
+        } = args;
+
+        const MAX_SCALAR_TARGET_LEN: usize = 16384;
+
+        // If target_len and fill (if specified) are constants, use the scalar
+        // fast path.
+        if let Some(target_len) = try_as_scalar_i64(&args[1]) {
+            let target_len: usize = match usize::try_from(target_len) {
+                Ok(n) if n <= i32::MAX as usize => n,
+                Ok(n) => {
+                    return exec_err!("lpad requested length {n} too large");

Review Comment:
   Yep, done (here and elsewhere).



-- 
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]

Reply via email to