shahwazreza opened a new pull request, #26957:
URL: https://github.com/apache/datafusion/pull/26957

   ## Which issue does this PR close?
   
   - Closes #26948.
   
   ## Rationale for this change
   
   `repeat` on a `LargeUtf8` string with a huge count, such as 
`repeat(arrow_cast('a', 'LargeUtf8'), 1152921504606846976)`, aborts the process 
or panics instead of returning an error. `Utf8` and `Utf8View` already return 
an error above `i32::MAX` bytes, but the `LargeUtf8` cap was `i64::MAX`, which 
admits sizes no allocation can satisfy.
   
   ## What changes are included in this PR?
   
   The issue asks whether to use a fixed cap or fallible allocation. This PR 
uses a fixed cap, `LARGE_UTF8_MAX_SIZE = u32::MAX`, in both the scalar and the 
array paths. I chose it over fallible allocation for two reasons:
   
   - The array path allocates through 
`GenericStringArrayBuilder::with_capacity`, which has no fallible variant. 
Making it fallible seems to belong to #22688 rather than this fix.
   - A cap gives the same error behavior as `Utf8`, and it matches DuckDB's 
string size limit, which the issue mentions.
   
   The exact cap value is a judgment call. I picked `u32::MAX` so `LargeUtf8` 
still allows larger results than `Utf8`. I'm happy to change it, for example to 
PostgreSQL's 1 GB, if reviewers prefer.
   
   As the issue notes, this does not guard against an allocation under the cap 
that succeeds under overcommit and fails later.
   
   ## What is the testing strategy for this PR?
   
   Two unit tests in `repeat.rs` use a count of `1 << 60` with `LargeUtf8`. One 
covers the scalar path through `test_function!`, and one covers the array path. 
Both previously aborted the test process. Now they get the overflow error.
   
   ## Are there any user-facing changes?
   
   `repeat` now returns an error for `LargeUtf8` results larger than `u32::MAX` 
bytes instead of attempting them.
   


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