avro icon indicating copy to clipboard operation
avro copied to clipboard

AVRO-3254: Automatically scale up or down decimal values when serializing

Open nathanscottdaniels opened this issue 3 years ago • 1 comments

Make sure you have checked all steps below.

Jira

  • [X] My PR addresses the following Avro Jira issues and references them in the PR title.
    • https://issues.apache.org/jira/browse/AVRO-3254

Tests

  • [X] My PR adds the following unit tests OR does not need testing for this extremely good reason:
    • TestDecimalScalesDown
    • TestDecimalScalesDownToZero
    • TestDecimalScalesUp
    • TestAvroDecimalReScaling (65 test cases)

Commits

  • [X] My commits all reference Jira issues in their subject lines. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Documentation

  • [X] In case of new functionality, my PR adds documentation that describes how to use it.
    • All the public functions and the classes in the PR contain ~Javadoc~ xml doc that explain what it does

nathanscottdaniels avatar Nov 16 '21 16:11 nathanscottdaniels

Hello! I have a quick concern about this PR -- modifying the scale of an AvroDecimal makes it no longer equal to its old value, so the serialize/deserialize would make the datum, or any record containing the datum (for example), no longer equal to its original value.

I would be worried that this would have some unexpected side effects. Any thoughts?

We should take a look at what the other SDKs are doing.

RyanSkraba avatar Jan 21 '22 10:01 RyanSkraba