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

replace the arithmetic op for decimal array op decimal array using arrow kernel #4648

Merged

Conversation

liukun4515
Copy link
Contributor

Which issue does this PR close?

Closes #4289

The behavior of divide for decimal array with decimal array was changed.

In the previous implementation, we will check the 0 for dividend, but in the kernel divide_opt of arrow-rs, the result will be None if the right is zero

cc @alamb

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the physical-expr Physical Expressions label Dec 15, 2022
alamb
alamb previously approved these changes Dec 15, 2022
@@ -503,9 +444,6 @@ mod tests {
let left_decimal_array = create_decimal_array(&[Some(101)], 10, 1);
let right_decimal_array = create_decimal_array(&[Some(0)], 1, 1);

let err =
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this test removed as it is now covered by the new arithmetic_divide_zero test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No,
The behavior of divide for decimal array with decimal array was changed.

In the previous implementation, we will check the 0 for dividend, but in the kernel divide_opt of arrow-rs, the result will be None if the right is zero

@alamb alamb dismissed their stale review December 15, 2022 18:35

CI is failing

@liukun4515
Copy link
Contributor Author

From this changes, I find some inconsistent behavior for divide about zero.

❯ \d left
+---------------+--------------+------------+-------------+-----------+-------------+
| table_catalog | table_schema | table_name | column_name | data_type | is_nullable |
+---------------+--------------+------------+-------------+-----------+-------------+
| datafusion    | public       | left       | c           | Int32     | YES         |
+---------------+--------------+------------+-------------+-----------+-------------+
1 row in set. Query took 0.054 seconds.
❯ select c/0 from left;
ArrowError(DivideByZero)
❯ select 10/0;
+----------------------+
| Int64(10) / Int64(0) |
+----------------------+
|                      |
+----------------------+

The difference is from the arrow-rs kernel divide_scalar and divide_opt.

In the divide_scalar, it will check the zero for the right, but in the divide_opt, the result will be replaced with NULL if the right value is zero.

cc @alamb

@github-actions github-actions bot added the core Core DataFusion crate label Dec 16, 2022
@alamb
Copy link
Contributor

alamb commented Dec 16, 2022

In the divide_scalar, it will check the zero for the right, but in the divide_opt, the result will be replaced with NULL if the right value is zero.

I recommend a ticket to fix the inconsistency upstream

@liukun4515
Copy link
Contributor Author

In the divide_scalar, it will check the zero for the right, but in the divide_opt, the result will be replaced with NULL if the right value is zero.

I recommend a ticket to fix the inconsistency upstream

agree,

ci failed with the clippy issue.

@liukun4515 liukun4515 merged commit 30de028 into apache:master Dec 19, 2022
@ursabot
Copy link

ursabot commented Dec 19, 2022

Benchmark runs are scheduled for baseline = 09d3378 and contender = 30de028. 30de028 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

@liukun4515 liukun4515 deleted the replace_arithmetic_kernel_op_4289 branch December 20, 2022 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

replace the operation about decimal to the arrow-rs kernel
3 participants