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

Add subtrait support for IS NULL and IS NOT NULL #8093

Merged
merged 2 commits into from
Nov 12, 2023

Conversation

tgujar
Copy link
Contributor

@tgujar tgujar commented Nov 8, 2023

Which issue does this PR close?

Closes #8087.

What changes are included in this PR?

Support for IS NULL and IS NOT NULL in Substrait producer and consumer. Also includes basic tests for this functionality.

Are these changes tested?

Yes

Are there any user-facing changes?

No

@tgujar tgujar marked this pull request as ready for review November 9, 2023 18:44
@alamb alamb changed the title added match arms and tests for is null Add subtrait support for IS NULL and IS NOT NULL Nov 10, 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 for the contribution @tgujar -- very nice 👏

I had some small style suggestions, but I also think this PR could be merged and they could be addressed as a follow on (or never). Just let me know what you want to do

@@ -880,6 +886,42 @@ pub async fn from_substrait_rex(
ScalarFunctionType::ILike => {
make_datafusion_like(true, f, input_schema, extensions).await
}
ScalarFunctionType::IsNull => {
let arg = f.arguments.first().ok_or_else(|| {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if it matters, but this code doesn't check for f.arguments.len() > 1 so I think it will silently ignore any arguments after the first.

The same comment applies to IsNotNull

Copy link
Contributor

Choose a reason for hiding this comment

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

On review, this is the same pattern used elsewhere in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for merging my PR! I think I could add checks for arg length here and also in other places where they are required in another PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you @tgujar -- A follow on to make the argument checking handle too many arguments would be most appreciated. Thank you 🙏

}];

let function_name = "is_null".to_string();
let function_anchor = _register_function(function_name, extension_info);
Copy link
Contributor

Choose a reason for hiding this comment

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

Very minor, but why not call this function_reference to match the field name used below?

Copy link
Contributor

Choose a reason for hiding this comment

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

While reviewing the code again, I found this simply follows the same pattern as the existing substrait code, so looks good to me

Copy link
Contributor

@alamb alamb Nov 13, 2023

Choose a reason for hiding this comment

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

@tgujar if you have time, it would also be awesome if you could make a PR that renames this variable (and other uses of _register_function to function_reference which I think would make the code cleaner

@alamb
Copy link
Contributor

alamb commented Nov 12, 2023

Thanks again @tgujar

@alamb alamb merged commit e18c709 into apache:main Nov 12, 2023
23 checks passed
@tgujar tgujar deleted the substrait_is_null branch November 12, 2023 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Substrait support for IS NULL and IS NOT NULL operators
2 participants