shahwazreza commented on code in PR #26957:
URL: https://github.com/apache/datafusion/pull/26957#discussion_r4485867173


##########
datafusion/functions/src/string/repeat.rs:
##########
@@ -519,6 +552,35 @@ mod tests {
         );
     }
 
+    #[test]
+    fn test_repeat_large_string_array_exceeds_max_size() {
+        let strings: ArrayRef = 
Arc::new(LargeStringArray::from(vec![Some("a")]));
+        let counts: ArrayRef = Arc::new(Int64Array::from(vec![Some(1 << 60)]));
+
+        let err = super::repeat(&strings, &counts).unwrap_err().to_string();
+        assert!(
+            err.contains("string size overflow on repeat"),
+            "unexpected error: {err}"
+        );
+    }
+
+    #[test]
+    fn test_repeat_large_string_array_total_exceeds_max_size() {
+        // Each row is under the cap, but together they exceed it.
+        let strings: ArrayRef =
+            Arc::new(LargeStringArray::from(vec![Some("a"), Some("a")]));
+        let counts: ArrayRef = Arc::new(Int64Array::from(vec![
+            Some(3_000_000_000),
+            Some(3_000_000_000),
+        ]));
+
+        let err = super::repeat(&strings, &counts).unwrap_err().to_string();
+        assert!(
+            err.contains("string size overflow on repeat"),
+            "unexpected error: {err}"
+        );
+    }

Review Comment:
   Good point. With the total check in place, the single-row test can't fail on 
its own, since one huge row also pushes the total over the cap, so I removed it 
and switched the total test to your version in 8ca4139. 
   
   Thanks for your valuable suggestions. They made this very easy to fix!



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