dmitry-chirkov-dremio opened a new pull request, #49421:
URL: https://github.com/apache/arrow/pull/49421
### Rationale for this change
The `castVARCHAR` functions in Gandiva have memory allocation inefficiencies
and missing edge case handling. See GH-49420 for details.
### What changes are included in this PR?
**Functional fixes:**
- `bool`: Remove unused 5-byte arena allocation; return string literal
directly
- `int32`/`int64`: Add handling for `len=0` (return empty string) and
`len<0` (set error)
**Memory allocation optimizations:**
- `int32`/`int64`: Use stack buffer with digit-pair conversion, allocate
only `min(len, actual_size)` bytes
- `date64`: Allocate only `min(len, 10)` bytes upfront (output is always
"YYYY-MM-DD")
- `float32`/`float64`: Allocate only `min(len, 24)` bytes upfront (max
output length)
**Code cleanup:**
- Extract common code into helper macros to reduce duplication
### Are these changes tested?
Yes. Added tests for `len=0` and `len<0` edge cases for int64, date64,
float32, float64, and bool types. All existing Gandiva tests pass.
### Are there any user-facing changes?
No. Users will see reduced memory usage and proper error messages for
invalid len parameter values.
Note: Error messages for negative `len` remain different between precompiled
("Output buffer length can't be negative") and interpreted ("Buffer length
cannot be negative") code paths, preserving existing behavior.
--
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]