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

using Decimal(0) make system panicked #3665

Closed
waitingkuo opened this issue Sep 30, 2022 · 6 comments · Fixed by #3818
Closed

using Decimal(0) make system panicked #3665

waitingkuo opened this issue Sep 30, 2022 · 6 comments · Fixed by #3818
Labels
bug Something isn't working

Comments

@waitingkuo
Copy link
Contributor

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

DataFusion CLI v12.0.0
❯ select 1::decimal(0);
thread 'main' panicked at 'attempt to subtract with overflow', /Users/willy/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/arrow-23.0.0/src/datatypes/datatype.rs:1001:46
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior
A clear and concise description of what you expected to happen.

show something like this

select 10::decimal(1);
ArrowError(InvalidArgumentError("10 is too large to store in a Decimal128 of precision 1. Max is 9"))

Additional context
Add any other context about the problem here.

@waitingkuo waitingkuo added the bug Something isn't working label Sep 30, 2022
@HaoYang670
Copy link
Contributor

This is a bug in the validate_decimal_precision in arrow-rs: https://github.com/apache/arrow-rs/blob/master/arrow-data/src/decimal.rs#L755-L756

Should we file an issue in arrow-rs?

cc @liukun4515

@HaoYang670 HaoYang670 added the waiting-on-upstream PR is waiting on an upstream dependency to be updated label Oct 1, 2022
@alamb
Copy link
Contributor

alamb commented Oct 3, 2022

We should file a bug (and even better a fix!) upstream 👍

@liukun4515
Copy link
Contributor

liukun4515 commented Oct 4, 2022

This is a bug in the validate_decimal_precision in arrow-rs: https://github.com/apache/arrow-rs/blob/master/arrow-data/src/decimal.rs#L755-L756

Should we file an issue in arrow-rs?

cc @liukun4515

@HaoYang670 @waitingkuo I think we should file an issue or pr to check the precision which should be greater than 0

@HaoYang670
Copy link
Contributor

BTW, we could use nonZeroU8 to represent precision: https://doc.rust-lang.org/std/num/struct.NonZeroU8.html

@HaoYang670
Copy link
Contributor

We can fix this bug without waiting for arrow-rs. I will file a PR.

@HaoYang670 HaoYang670 removed the waiting-on-upstream PR is waiting on an upstream dependency to be updated label Oct 13, 2022
@waitingkuo
Copy link
Contributor Author

LGTM, thank you @HaoYang670

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants