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

inconsistent behavior for divide zero: divide_opt and divide_scalar #4669

Closed
liukun4515 opened this issue Dec 19, 2022 · 2 comments · Fixed by #7405
Closed

inconsistent behavior for divide zero: divide_opt and divide_scalar #4669

liukun4515 opened this issue Dec 19, 2022 · 2 comments · Fixed by #7405

Comments

@liukun4515
Copy link
Contributor

    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

Originally posted by @liukun4515 in #4648 (comment)

@Jefffrey
Copy link
Contributor

Seems related to #3849 as well

@liukun4515
Copy link
Contributor Author

Seems related to #3849 as well

Thanks @Jefffrey we need to reconsider divide/0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants