feat(sql): introduce more array functions#5771
Merged
bluestreak01 merged 92 commits intomasterfrom Jul 1, 2025
Merged
Conversation
indexOfAssumeSorted(array) and arraySum(array) function.|
GitHub Actions - Rebuild Native Libraries seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
mtopolnik
reviewed
Jul 1, 2025
core/src/main/java/io/questdb/griffin/engine/functions/array/DoubleUnaryArrayAccessor.java
Show resolved
Hide resolved
mtopolnik
approved these changes
Jul 1, 2025
mtopolnik
previously approved these changes
Jul 1, 2025
bluestreak01
reviewed
Jul 1, 2025
puzpuzpuz
reviewed
Jul 1, 2025
...main/java/io/questdb/griffin/engine/functions/array/DoubleScalarDivArrayFunctionFactory.java
Show resolved
Hide resolved
puzpuzpuz
reviewed
Jul 1, 2025
...java/io/questdb/griffin/engine/functions/array/DoubleScalarSubtractArrayFunctionFactory.java
Show resolved
Hide resolved
Contributor
[PR Coverage check]😍 pass : 810 / 893 (90.71%) file detail
|
mtopolnik
approved these changes
Jul 1, 2025
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.
1. New array functions
array_position(array, elem)
Returns the index (1-based) of the first
elemin the 1Darrayif it exists, otherwise NULL.insertion_point(array, x, [ahead_of_equal])
Looks for the insertion position of
xin the 1D array, which must be sorted. Returns its index (1-based).When the array contains elements equal to
x:ahead_of_equalis true, the function returns the position of the first equal element.ahead_of_equaldefaults tofalse.array_sum(array)
Returns the sum of elements in the array.
array_count(array)
Returns the number of not NaN elements in the source array.
array_avg(array)
Returns the average of elements in the array.
array_cum_sum(array)
Returns the array of cumulative sums of elements in the array. If array is multidimensional, flattens it first into a single dimension.
dot_product(array1, array2)
Returns the dot product of the two arrays, which must have the same shape.
shift(array1, x, [fill_value])
Shift array elements along the innermost dimension of the array. When x > 0, it indicates a rightward shift by x positions; otherwise, it signifies a leftward shift by x positions.All newly vacated positions are filled with
fill_value, which defaults toNull.(+ - * /)between array and scalar value+-*/2. Auto-broadcasting for binary array operators
Broadcast rules on
(+ - * /)between arrayshttps://numpy.org/doc/stable/user/basics.broadcasting.html#general-broadcasting-rules
Two array shapes are compatiable only when all of their dimensions are compatible.
Starting with the rightmost dimension moving to the left, two dimensions are compatible when:
Broadcast rules on
matmulfunction3. Performance
isVanillato cover all cases where all the array elements occur in a contiguous block, arranged in the row-major order. This may be an arbitrary contiguous block within the one covered by the underlying flat array view.arraySum,arrayAvgandarrayCountuse vectorized operations when the array is vanilla.