Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
Description
https://github.com/apache/arrow/blame/bfac60dd73bffa5f7bcefc890486268036182278/cpp/src/arrow/util/decimal.cc#L365-L373 in Decimal128::FromString makes *out depend on whether scale is null, and makes *scale depend on whether out is null. For example, given an input "1e2",
- if out is not null and scale is not null, then *out is 1
- if out is null and scale is not null, then *scale is -2
- if neither out nor scale is null, then *out is 100 and *scale is 0
It is very counter-intuitive that when an additional output-only pointer is given for receiving extra info, it alters the value of another output.
Similarly, *precision is also affected by presence of out and scale.
The block of adjustment was added in https://github.com/apache/arrow/commit/bfac60dd73bffa5f7bcefc890486268036182278 for preventing negative scale output (https://issues.apache.org/jira/browse/ARROW-2177). While the motivation looks reasonable, the change is not sufficient (see case #2 above).
I think we should make the outputs independent of one-another. For the input "1e2", *out should be 100 if out is not null, and *scale should be 0 if scale is not null.
Attachments
Issue Links
- links to