Repository navigation
Gandiva: Add missing SQL function implementations - #115
Closed
StevenMPhillips wants to merge 17 commits into
Closed
StevenMPhillips wants to merge 17 commits into
StevenMPhillips wants to merge 17 commits into
Conversation
Add the mathematical constant pi() function to Gandiva. - Returns the value of mathematical constant π (3.14159265358979...) - No input parameters - Returns double (float64) - Always non-null This enables Gandiva to natively execute queries using pi() without falling back to Java execution.
Add the find_in_set(needle, haystack) function to Gandiva.
- Searches for a string in a comma-separated list
- Returns 1-indexed position if found, 0 if not found
- Example: find_in_set('b', 'a,b,c') returns 2
This enables Gandiva to natively execute queries using find_in_set()
without falling back to Java execution.
Formats a number with commas and fixed decimal places. Examples: - format_number(1234567.89, 2) -> "1,234,567.89" - format_number(1000.0, 0) -> "1,000" - format_number(-1234.5, 2) -> "-1,234.50" Handles NaN, Infinity, negative numbers, and edge cases.
Generates a random UUID v4 string (RFC 4122) in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Uses thread-local mt19937_64 PRNG, sets proper version (4) and variant (10xx) bits per the RFC specification.
- lshift(value, bits): left shift (zero-fill on right) - rshift(value, bits): arithmetic right shift (sign-extends) - rshiftunsigned(value, bits): logical right shift (zero-fill on left) Supports int32 and int64 types. Handles edge cases to avoid C++ UB: - bits < 0 or >= bitwidth returns 0 for lshift/rshiftunsigned - rshift with bits >= bitwidth returns -1 for negative, 0 for non-negative
- rand_integer(max): returns random int in [0, max] - rand_integer(min, max): returns random int in [min, max] Uses thread-local mt19937 PRNG with uniform distribution. Handles min > max by swapping arguments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds native Gandiva implementations for several SQL functions that were previously Java-only in Dremio.
Functions Implemented
Testing
Each function includes unit tests. Requesting CI run to validate.
Notes