zml1206 opened a new pull request, #13668: URL: https://github.com/apache/gluten/pull/13668
## What changes are proposed in this pull request? Fix native Parquet writes failing with: `WrappedMemoryPool: Error reallocating 0 bytes` [Velox #17986](https://github.com/facebookincubator/velox/pull/17986) introduced dictionary passthrough for eligible string and binary vectors in the Parquet writer. This path can expose a pre-existing incompatibility in Gluten's Arrow memory allocator. When dictionary statistics select only empty strings or nulls from a dictionary containing unused non-empty values, Arrow may shrink its value buffer to zero. `StdMemoryAllocator::reallocateAligned` currently rejects this valid operation, causing the native Parquet write to fail. Update `StdMemoryAllocator::reallocateAligned` to support zero-size reallocations: - Preserve a non-null, aligned pointer that can be freed or grown again. - Update logical memory accounting correctly. - Preserve the original allocation and accounting if allocation fails. - Continue rejecting negative allocation sizes. Add native regression tests covering zero-size reallocation, memory accounting, Arrow buffer operations, and dictionary selections. Add a Spark regression test in `VeloxParquetWriteSuite`, reusing `checkNativeWrite` to verify native writer execution. ## How was this patch tested? - Confirmed that five targeted native tests fail against the unmodified `main` allocator. - All eight native tests pass with the fix in a local C++20 build using Arrow 15, AddressSanitizer, and UndefinedBehaviorSanitizer. - Verified 16 local Arrow Parquet writer scenarios covering dictionary and flat inputs, empty strings and nulls, dictionary output enabled and disabled, and table and record-batch writing. - Passed C++ and Scala formatting, license-header checks, and `git diff --check`. - The Spark regression test has been added but has not yet been executed because the required Velox/JNI runtime is unavailable locally. Full Spark integration validation remains pending. ## Was this patch authored or co-authored using generative AI tooling? Generated-by: Codex (GPT-6) -- 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]
