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

Add nanvl builtin function #7171

Merged
merged 5 commits into from
Aug 2, 2023
Merged

Add nanvl builtin function #7171

merged 5 commits into from
Aug 2, 2023

Conversation

sarutak
Copy link
Member

@sarutak sarutak commented Aug 1, 2023

Which issue does this PR close?

Closes #7170

Rationale for this change

I propose to add nanvl builtin function which is provided by some RDBMS.
nanvl(x, y) returns x if x is not NaN otherwise returns y.
It could be convenience to handle missing data.

What changes are included in this PR?

nullvl is added as a math builtin function.

Are these changes tested?

Added new tests.

Are there any user-facing changes?

New builtin function is added but it doesn't break compatibility.

@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Physical Expressions core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Aug 1, 2023
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

This looks great -- thank you very much @sarutak 🙏

Can you please also add an entry to the user guide about this function https://github.com/apache/arrow-datafusion/blob/main/docs/source/user-guide/sql/scalar_functions.md#atan2 ?

We don't yet have automated documentation I am afraid (#3092)


# nanvl
query RRR
SELECT nanvl(asin(10), 1.0), nanvl(1.0, 2.0), nanvl(asin(10), asin(10))
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 for testing when both args are NAN

@sarutak
Copy link
Member Author

sarutak commented Aug 1, 2023

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank. you @sarutak

@alamb alamb merged commit 354dc19 into apache:main Aug 2, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions physical-expr Physical Expressions sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add nanvl builtin function
2 participants