gonappuccino commented on code in PR #26958:
URL: https://github.com/apache/datafusion/pull/26958#discussion_r4489012686


##########
datafusion/functions/src/unicode/lpad.rs:
##########
@@ -345,4 +347,49 @@ mod tests {
 
         Ok(())
     }
+
+    fn array_args(lengths: Vec<i64>) -> Vec<ColumnarValue> {
+        vec![
+            ColumnarValue::Array(Arc::new(StringArray::from(vec!["hi"; 
lengths.len()]))),
+            ColumnarValue::Array(Arc::new(Int64Array::from(lengths))),
+        ]
+    }
+
+    #[test]
+    fn test_array_length_out_of_range() -> Result<()> {
+        test_function!(
+            LPadFunc::new(),
+            array_args(vec![-1]),
+            Ok(Some("")),
+            &str,
+            Utf8,
+            StringArray
+        );
+        test_function!(
+            LPadFunc::new(),
+            array_args(vec![1 << 62]),
+            exec_err!(
+                "lpad requested length {} too large, maximum allowed length is 
{}",
+                1i64 << 62,
+                i32::MAX
+            ),
+            &str,
+            Utf8,
+            StringArray
+        );
+        test_function!(
+            LPadFunc::new(),
+            array_args(vec![i64::MAX, i64::MAX]),
+            exec_err!(
+                "lpad requested length {} too large, maximum allowed length is 
{}",
+                i64::MAX,
+                i32::MAX
+            ),
+            &str,
+            Utf8,
+            StringArray
+        );
+
+        Ok(())
+    }

Review Comment:
   Done, replaced them with `test_pad_data_capacity` in `common.rs`. It now 
fails if either `.filter` or `.min` is removed.



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