sam-1112 commented on code in PR #27643:
URL: https://github.com/apache/datafusion/pull/27643#discussion_r4658476676


##########
datafusion/functions/src/string/repeat.rs:
##########
@@ -570,6 +579,51 @@ mod tests {
         );
     }
 
+    #[test]
+    fn test_repeat_string_array_total_exceeds_max_size() {
+        // Each row is at the cap, but the total is larger than any allocation
+        // can satisfy, so a missing total check fails at once.
+        let n = 1 << 17;
+        let strings: ArrayRef = Arc::new(StringArray::from(vec![Some("a"); 
n]));
+        let counts: ArrayRef = Arc::new(Int64Array::from(vec![Some(i32::MAX as 
i64); n]));
+
+        let err = super::repeat(&strings, &counts)
+            .unwrap_err()
+            .strip_backtrace();
+        assert_eq!(
+            err,
+            format!(
+                "Execution error: string size overflow on repeat, max size is 
{}, but got {}",
+                i32::MAX,
+                n * i32::MAX as usize
+            )
+        );
+    }
+
+    #[test]
+    fn test_repeat_string_array_total_overflow_small_batch() {
+        // Two rows of ~1 GiB each: each row fits in Utf8 (<= i32::MAX), but 
their
+        // combined output exceeds i32::MAX by one byte, which cannot be 
represented
+        // in an Arrow Utf8 array.
+        let strings: ArrayRef = Arc::new(StringArray::from(vec![Some("a"), 
Some("a")]));
+        let counts: ArrayRef = Arc::new(Int64Array::from(vec![

Review Comment:
   Could we use `Some(1_i64 << 30)` for both counts and update the expected 
total to `1usize << 31`? The current total is `i32::MAX + 2`, while the comment 
says it exceeds the limit by one byte. Using equal counts would test the first 
unrepresentable total, `i32::MAX + 1`.



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