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

Return error when internal multiplication overflowing in decimal division kernel #6833

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

viirya
Copy link
Member

@viirya viirya commented Jul 3, 2023

Which issue does this PR close?

Related #6794.

Rationale for this change

Before we figure a proper way to address the issue, we should return error for the overflowing case instead of returning incorrect result.

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added physical-expr Physical Expressions core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Jul 3, 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.

The code does what the PR says it does 👍

I defer to you (or maybe @liukun4515 ) for if this is the desired behavior

statement ok
insert into foo VALUES (1, 5);

query error DataFusion error: Arrow error: Compute error: Overflow happened on: 100000000000000000000 \* 100000000000000000000000000000000000000
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW this is what postgres does (treats it like a float, I think):

postgres=# create table foo (a DECIMAL(38, 20), b DECIMAL(38, 0));
CREATE TABLE
postgres=# insert into foo VALUES (1, 5);
INSERT 0 1
postgres=# select a / b from foo;
        ?column?
------------------------
 0.20000000000000000000
(1 row)

@viirya
Copy link
Member Author

viirya commented Jul 6, 2023

Thanks @alamb .

Before we can return more correct result for the case, we should return error instead of incorrect result as reported in the issue. That is the purpose of this PR.

@viirya viirya merged commit eb03b4f into apache:main Jul 6, 2023
20 checks passed
alamb pushed a commit to alamb/datafusion that referenced this pull request Jul 6, 2023
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 sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants