dmitry-chirkov-dremio opened a new pull request, #55607: URL: https://github.com/apache/arrow/pull/55607
### Rationale for this change `LLVMTypes::int_constant` builds `llvm::APInt(N, val)` without the signed flag. For a negative value narrower than 64 bits, the `APInt` has bits set above its width. With optimization on, Gandiva returns wrong results, for example `if (k == 0) 10 else -5` returns `-5` for every row. The same fix exists in the Dremio fork (dremio/arrow 3950ea6e41). ### What changes are included in this PR? This PR currently contains only the tests. They are expected to fail until the fix is pushed as the second commit. The fix is a one-line change in `llvm_types.h`: pass `std::is_signed<ctype>::value` as the signed flag of `APInt`. ### Are these changes tested? Yes. The new tests for the integer constants and for `IF` with negative literals fail before the fix and pass afterward. ### Are there any user-facing changes? No. **This PR contains a "Critical Fix".** It fixes a bug that produced incorrect data. ### Was AI used for this PR? AI tools helped investigate the bug and write the tests and description. **PR code and description written by:** - [ ] Human - [x] AI **Reviewed before submission by:** - [ ] Human - [ ] AI - [ ] Not reviewed -- 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]
