You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "dmitry-chirkov-dremio (via GitHub)" <gi...@apache.org> on 2026/03/03 17:40:13 UTC
[PR] GH-49441: [C++][Gandiva] Add rand_integer function [arrow]
dmitry-chirkov-dremio opened a new pull request, #49442:
URL: https://github.com/apache/arrow/pull/49442
### Rationale for this change
Add `rand_integer` function to Gandiva to generate random integers, complementing the existing `rand`/`random` functions that generate random doubles. This provides native integer random number generation and offers a more efficient alternative to `CAST(rand() * range AS INT)`.
### What changes are included in this PR?
- Add `RandomIntegerGeneratorHolder` class following the existing `RandomGeneratorHolder` pattern
- Implement three function signatures:
- `rand_integer()` → int32 in range [INT32_MIN, INT32_MAX]
- `rand_integer(int32 range)` → int32 in range [0, range-1]
- `rand_integer(int32 min, int32 max)` → int32 in range [min, max] inclusive
- Add parameter validation (range > 0, min <= max) at expression compilation time
- Add 8 unit tests covering all signatures and edge cases
- Use `std::uniform_int_distribution<int32_t>` with Mersenne Twister engine
### Are these changes tested?
Yes, added 8 unit tests in `random_generator_holder_test.cc`:
- `NoParams` - verifies full int32 range
- `WithRange` - verifies [0, range-1] bounds
- `WithMinMax` - verifies [min, max] inclusive bounds
- `WithNegativeMinMax` - verifies negative range handling
- `InvalidRangeZero` - verifies range=0 is rejected
- `InvalidRangeNegative` - verifies negative range is rejected
- `InvalidMinGreaterThanMax` - verifies min > max is rejected
- `NullRangeDefaultsToOne` - verifies null parameter handling
### Are there any user-facing changes?
Yes, this adds a new `rand_integer` function to Gandiva with three signatures as described above.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49441: [C++][Gandiva] Add rand_integer function [arrow]
Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #49442:
URL: https://github.com/apache/arrow/pull/49442#issuecomment-4014877423
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit aa1cabea2e53a82cc7bb250a39a0c90c08809909.
There were no benchmark performance regressions. 🎉
The [full Conbench report](https://github.com/apache/arrow/runs/66106252692) has more details. It also includes information about 7 possible false positives for unstable benchmarks that are known to sometimes produce 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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49441: [C++][Gandiva] Add rand_integer function [arrow]
Posted by "dmitry-chirkov-dremio (via GitHub)" <gi...@apache.org>.
dmitry-chirkov-dremio commented on PR #49442:
URL: https://github.com/apache/arrow/pull/49442#issuecomment-3993145273
> Once semantics are clarified and covered, this should be in good shape.
@StevenMPhillips pushed a new commit.
I don't want to go overboard with signature rework wrt literals - we seem to have a bit of inconsistency between regexp_replace/regexp_extract, like/ilike, to_date and rand functions. I adjusted implementation to match regexp_replace with commented out argument names.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49441: [C++][Gandiva] Add rand_integer function [arrow]
Posted by "dmitry-chirkov-dremio (via GitHub)" <gi...@apache.org>.
dmitry-chirkov-dremio commented on PR #49442:
URL: https://github.com/apache/arrow/pull/49442#issuecomment-3993204738
Pipeline failed due to ongoing GitHub issues. How could PR owner retrigger it?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49441: [C++][Gandiva] Add rand_integer function [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on PR #49442:
URL: https://github.com/apache/arrow/pull/49442#issuecomment-4015660366
@StevenMPhillips Could you our merge tool next time?
https://github.com/apache/arrow/tree/main/dev#how-to-merge-a-pull-request
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49441: [C++][Gandiva] Add rand_integer function [arrow]
Posted by "StevenMPhillips (via GitHub)" <gi...@apache.org>.
StevenMPhillips merged PR #49442:
URL: https://github.com/apache/arrow/pull/49442
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49441: [C++][Gandiva] Add rand_integer function [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on PR #49442:
URL: https://github.com/apache/arrow/pull/49442#issuecomment-3994354370
Only Apache Arrow committers can retrigger jobs.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49441: [C++][Gandiva] Add rand_integer function [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on PR #49442:
URL: https://github.com/apache/arrow/pull/49442#issuecomment-3994354859
@lriggs @akravchukdremio @xxlaykxx You may want to review this.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org