Skip to content
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

[FEA] elementAt, getArrayItem and getMapValue have different behaviors since Spark-3.1.1 when honoring AnsiMode #2272

Closed
3 tasks done
wjxiz1992 opened this issue Apr 27, 2021 · 0 comments · Fixed by #2350
Closed
3 tasks done
Assignees
Labels
task Work required that improves the product but is not user facing

Comments

@wjxiz1992
Copy link
Collaborator

wjxiz1992 commented Apr 27, 2021

Is your feature request related to a problem? Please describe.
apache/spark#30297 introduce different behaviors for element_at, getArrayItem and getMapValue when invalid index or key is given to lhs with ansi mode enabled and disabled.

For select element_at(Array(1,2,3), 4):

Spark 3.0.2 + spark.sql.ansi.enabled=true:

+-----------------------------+
|element_at(array(1, 2, 3), 4)|
+-----------------------------+
|                         null|
+-----------------------------+

Spark 3.1.1 + spark.sql.ansi.enabled=true:

java.lang.ArrayIndexOutOfBoundsException: Invalid index: 4, numElements: 3

For select element_at(map(1, 'a', 2, 'b'), 3):

Spark 3.0.2 + spark.sql.ansi.enabled=true:

+------------------------------+
|element_at(map(1, a, 2, b), 3)|
+------------------------------+
|                          null|
+------------------------------+

Spark 3.1.1 + spark.sql.ansi.enabled=true:

java.util.NoSuchElementException: Key 3 does not exist.

Initial support for elementAt, getArrayItem will always return null for invalid index or key.

Describe the solution you'd like
Put corresponding code into 3.1.1 shim layers.

  • GetArrayItem
  • GetMapValue
  • ElementAt

Additional context
Initial PR: #2260

@wjxiz1992 wjxiz1992 added feature request New feature or request ? - Needs Triage Need team to review and classify labels Apr 27, 2021
@wjxiz1992 wjxiz1992 self-assigned this Apr 27, 2021
@sameerz sameerz removed the ? - Needs Triage Need team to review and classify label Apr 27, 2021
@sameerz sameerz added this to the May 10 - May 21 milestone May 11, 2021
@sameerz sameerz added task Work required that improves the product but is not user facing and removed feature request New feature or request labels Jun 4, 2021
@nartal1 nartal1 mentioned this issue Apr 5, 2022
49 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task Work required that improves the product but is not user facing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants