feat: add support for array_position expression#3172
Open
andygrove wants to merge 6 commits intoapache:mainfrom
Open
feat: add support for array_position expression#3172andygrove wants to merge 6 commits intoapache:mainfrom
andygrove wants to merge 6 commits intoapache:mainfrom
Conversation
Implements Spark's array_position function which returns the 1-based position of an element in an array, returning 0 if not found. This required a custom Rust implementation because DataFusion's array_position returns UInt64 and null when not found, while Spark returns Int64 (LongType) and 0. Key implementation details: - Returns Int64 to match Spark's LongType - Returns 0 when element is not found (Spark behavior) - Returns null when array is null or search element is null - Supports both List and LargeList array types Closes apache#3153 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3172 +/- ##
============================================
+ Coverage 56.12% 59.96% +3.84%
- Complexity 976 1462 +486
============================================
Files 119 175 +56
Lines 11743 16180 +4437
Branches 2251 2684 +433
============================================
+ Hits 6591 9703 +3112
- Misses 4012 5128 +1116
- Partials 1140 1349 +209 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
# Conflicts: # docs/source/user-guide/latest/configs.md # native/spark-expr/src/comet_scalar_funcs.rs
Member
Author
|
Moving this to draft until #3328 is merged |
Move array_position tests from CometArrayExpressionSuite to a SQL file test and fall back to Spark when all arguments are literals. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Closes #3157
Summary
array_positionfunctionImplementation Details
This required a custom Rust implementation because DataFusion's
array_positionreturnsUInt64andnullwhen not found, while Spark returnsInt64(LongType) and0.Key implementation details:
Int64to match Spark'sLongType0when element is not found (Spark behavior)nullwhen array isnullor search element isnullListandLargeListarray typesTest Plan
array_positioninCometArrayExpressionSuiteCloses #3153