warrenzhu25 opened a new issue, #7803: URL: https://github.com/apache/datafusion-comet/issues/7803
### Describe the bug Follow-up to #7497 / #7787. The JVM columnar shuffle now ends a batch before its rows could overflow Arrow's `i32` offsets: rows count three times when the schema holds a string, since `get_string` replaces each invalid UTF-8 byte with the three bytes of `U+FFFD`, and an encoded block past `i32::MAX` is split and encoded again. One case remains. A batch always takes its first row, so a **single row** whose string decodes to more than 2 GiB, about 716 MiB of mostly invalid UTF-8, still panics with `byte array offset overflow` inside arrow's `append_value`. Splitting cannot help, because one row cannot be split and the panic happens while the column is built, before any block exists. A panic that escapes the JNI entry point is undefined behavior (see AGENTS.md). ### Proposed fix - Check before each string append whether the builder's values plus the value would pass `i32::MAX`, and return a `CometError` instead of calling the panicking `append_value`. This covers top-level strings, strings nested in lists, maps and structs, and the dictionary builder. - In `SortedRowEncoder::encode_batch`, treat that error like an oversized block: drop the batch and encode each half. For a single row, return a clear error that the value does not fit in an Arrow string. - With an exact check in place, the ×3 row weight for string schemas could be removed, so batches of valid strings are no longer cut at a third of the byte budget. That needs a benchmark of the extra comparison per string. A single string that decodes past 2 GiB cannot be represented in `Utf8` at all; `LargeUtf8` would change the shuffle schema for every reader, so a clear error is the realistic outcome for that row. -- 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]
