-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-54240] Translate get array item catalyst expression to connector expression #52940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-54240] Translate get array item catalyst expression to connector expression #52940
Conversation
milastdbx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| @@ -326,6 +326,9 @@ class V2ExpressionBuilder(e: Expression, isPredicate: Boolean = false) extends L | |||
| case _: Sha2 => generateExpressionWithName("SHA2", expr, isPredicate) | |||
| case _: StringLPad => generateExpressionWithName("LPAD", expr, isPredicate) | |||
| case _: StringRPad => generateExpressionWithName("RPAD", expr, isPredicate) | |||
| case GetArrayItem(_, _, failOnError) if failOnError => | |||
| // Pushdown only if ANSI is enabled (fail on error) to be compatible with remote systems. | |||
| generateExpressionWithName("GET_ARRAY_ITEM", expr, isPredicate) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make new v2 expression as well to be able to pass failOnError argument, since get method in spark returns 0-indexed element of array, but it does not fail for index out of bounds, so it would be beneficial to pass failOnError to be able to support get method pushdown beside bracket access. WDYT @srielau @cloud-fan ?
| @@ -1629,6 +1629,12 @@ | |||
| ], | |||
| "sqlState" : "42846" | |||
| }, | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not find we have similar non legacy error. Legacy errors are usually too specific, e.g. unsupported function.
|
|
||
| public Expression getChildArray() { return this.childArray; } | ||
| public Expression getOrdinal() { return this.ordinal; } | ||
| public boolean getFailOnError() { return this.failOnError; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the get prefix in other v2 expressions such as Cast. Can we be consistent here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, makes sense 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
bbdd90a to
81ddd91
Compare
sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/GetArrayItem.java
Outdated
Show resolved
Hide resolved
…essions/GetArrayItem.java
|
thanks, merging to master/4.1! |
…or expression ### What changes were proposed in this pull request? - Support conversion of catalyst GetArrayItem expression to connector expression to allow data sources to implement pushdown of this expression ### Why are the changes needed? - To allow data sources (built-in and third-party) to implement pushdown of get array item ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? No testing needed, since we did not implement pushdowns yet ### Was this patch authored or co-authored using generative AI tooling? No Closes #52940 from urosstan-db/SPARK-54240-support-get-array-item-pushdown. Lead-authored-by: Uros Stankovic <[email protected]> Co-authored-by: Wenchen Fan <[email protected]> Co-authored-by: Uros Stankovic <[email protected]> Signed-off-by: Wenchen Fan <[email protected]> (cherry picked from commit 05b0543) Signed-off-by: Wenchen Fan <[email protected]>
|
Thank you all! |
What changes were proposed in this pull request?
Why are the changes needed?
Does this PR introduce any user-facing change?
No
How was this patch tested?
No testing needed, since we did not implement pushdowns yet
Was this patch authored or co-authored using generative AI tooling?
No