Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Optionally return null if element not exists map/array #4839

Merged
merged 1 commit into from
Feb 23, 2022

Conversation

amahussein
Copy link
Collaborator

fixes #4668

Signed-off-by: Ahmed Hussein (amahussein) a@ahussein.me

Spark 330 Added a new configuration spark.sql.ansi.failOnElementNotExists which controls whether throwing exceptions or returning null results when element not exists in the [] operator in array/map type. Spark-37750
The default value of the new configuration is true.

This PR adds support of the new flag for rapids.

@amahussein
Copy link
Collaborator Author

build

@amahussein
Copy link
Collaborator Author

build

Signed-off-by: Ahmed Hussein (amahussein) <a@ahussein.me>
* This is to support ANSI mode: optionally return null result if element not exists
* in array/map.
*/
def shouldFailOnElementNotExists(): Boolean = false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So by default it does not fail, even if ANSI is enabled?

Is the following correct for what we want?

version throw exception if key not found...
3.0.* Never
3.1.* If ANSI is enabled
3.2.* If ANSI is enabled
3.3.* If ANSI is enabled and strictIndexOperator is enabled (SQLConf includes both together in the helper method)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table is correct.

strictIndexOperator is true by default

@amahussein amahussein added the feature request New feature or request label Feb 22, 2022
@amahussein amahussein self-assigned this Feb 22, 2022
@revans2 revans2 added this to the Feb 14 - Feb 25 milestone Feb 23, 2022
@revans2 revans2 merged commit f986670 into NVIDIA:branch-22.04 Feb 23, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEA][Audit] - [SPARK-37750][SQL] ANSI mode: optionally return null result if element not exists in array/map
2 participants