You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "viirya (via GitHub)" <gi...@apache.org> on 2023/04/01 16:44:04 UTC
[GitHub] [arrow-datafusion] viirya opened a new issue, #5825: DataFusion incorrectly handle precision overflow when casting from integer to decimal
viirya opened a new issue, #5825:
URL: https://github.com/apache/arrow-datafusion/issues/5825
### Describe the bug
When casting from integer to decimal, if casted decimal exceeds the precision, e.g. cast(1234567 as decimal(7,3)), DataFusion doesn't handle it so the returned decimal is invalid. Whilst in Spark, the cast expression will return a null value indicating it's overflowing.
This is due to current behavior of `cast` kernel in arrow-rs. Although it checks if division or multiplication overflows in such cast operation, it doesn't check precision overflow. This is somehow related to decimal operation convention in arrow-rs, that is let user handle invalid values in decimal arrays. But for `cast` kernel, because it provides `CastOptions` which defines null behavior for invalid case, the behavior of not checking precision overflow becomes a bit inconsistent.
Proposed a fix at the upstream: https://github.com/apache/arrow-rs/pull/3996
We can add some tests in DataFusion after new arrow-rs is released.
### To Reproduce
In datafusion-cli, run the following query:
```
❯ select cast(1234567 as decimal(7,3));
+----------------+
| Int64(1234567) |
+----------------+
| 1234.567 |
+----------------+
1 row in set. Query took 0.016 seconds.
### Expected behavior
`cast(1234567 as decimal(7,3))` should return null.
### Additional context
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Dandandan closed issue #5825: DataFusion incorrectly handle precision overflow when casting from integer to decimal
Posted by "Dandandan (via GitHub)" <gi...@apache.org>.
Dandandan closed issue #5825: DataFusion incorrectly handle precision overflow when casting from integer to decimal
URL: https://github.com/apache/arrow-datafusion/issues/5825
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org