Skip to content

Conversation

@korowa
Copy link
Contributor

@korowa korowa commented Dec 26, 2022

Which issue does this PR close?

Closes #4205 .

Rationale for this change

Adding more options to call NULLIF in terms of signatures and inputs.

What changes are included in this PR?

  1. Calling arrow compute::nullif without intermediate type checking
  2. String typed inputs now allowed as NULLIF arguments
  3. Added support for literal as first argument for both Scalar-Array and Scalar-Scalar cases

Are these changes tested?

Unit tests for nullif_func added

Are there any user-facing changes?

@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates labels Dec 26, 2022
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.

Looks good to me -- thank you @korowa

One thing that might be helpful is to add some sql level tests, perhaps in the new sqllogictest
Or in new https://github.com/apache/arrow-datafusion/tree/master/datafusion/core/tests/sqllogictests

perhaps in https://github.com/apache/arrow-datafusion/blob/master/datafusion/core/tests/sqllogictests/test_files/select.slt?


use super::binary::array_eq_scalar;

/// Invoke a compute kernel on a primitive array and a Boolean Array
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 for this cleanup!

)),
(ColumnarValue::Scalar(lhs), ColumnarValue::Scalar(rhs)) => {
let val = match lhs.eq(rhs) {
true => ScalarValue::Null,
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this should actually be ScalarValue::Boolean(None) (aka a typed boolean null, rather than DataType::Null 🤔 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, thank you!

Fixed scalar-scalar case to return empty value with data type inherited from first argument, also added .slt for nullif

@github-actions github-actions bot added core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Dec 26, 2022
@@ -0,0 +1,98 @@
# Licensed to the Apache Software Foundation (ASF) under one
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@alamb alamb merged commit a8f1f8a into apache:master Dec 26, 2022
@ursabot
Copy link

ursabot commented Dec 26, 2022

Benchmark runs are scheduled for baseline = 8ec511e and contender = a8f1f8a. a8f1f8a is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nullif func states support for Boolean type, but fails if this is attempted

3 participants