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

Use checked division kernel #6792

Merged
merged 1 commit into from
Jun 29, 2023
Merged

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Jun 28, 2023

Which issue does this PR close?

Closes #6791

Rationale for this change

The current behaviour is inconsistent, can lead to nulls in non-nullable columns, and is pretty surprising.

A future iteration of the upstream arithmetic kernels is also likely to make this the only option - apache/arrow-rs#2647 (comment)

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added optimizer Optimizer rules physical-expr Changes to the physical-expr crates labels Jun 28, 2023

assert_eq!(simplify(expr), expected);
assert!(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is consistent with postgres 👍

postgres=# select 0 / 0;
ERROR:  division by zero

@alamb
Copy link
Contributor

alamb commented Jun 29, 2023

cc @viirya

@viirya
Copy link
Member

viirya commented Jun 29, 2023

Hmm, it is inconsistent. We should fix it. But we will prefer default behavior is to get null instead of query error. That is story of Spark but I agree DataFusion doesn't necessarily to follow it at all.

... nulls in non-nullable columns, and is pretty surprising.

Is it an issue? In Spark, Divide expression output is nullable always. I think producing null from non-nullable input columns is totally fine if it follows the expression's output type definition.

So the issue is more about inconsistency.

Looks okay to me.

@tustvold tustvold merged commit 283b8a1 into apache:main Jun 29, 2023
2010YOUY01 pushed a commit to 2010YOUY01/arrow-datafusion that referenced this pull request Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimizer Optimizer rules physical-expr Changes to the physical-expr crates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent Divide By Zero Behaviour
3 participants