Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-9913

[C++] Outputs of Decimal128::FromString depend on presence of one another

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 2.0.0
    • C++

    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",

      1. if out is not null and scale is not null, then *out is 1
      2. if out is null and scale is not null, then *scale is -2
      3. 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

          Activity

            People

              myzhong Mingyu Zhong
              myzhong Mingyu Zhong
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m