Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[transform][decimal] Add a function to down scale decimal #75

Open
aymkhalil opened this issue Jun 20, 2023 · 0 comments
Open

[transform][decimal] Add a function to down scale decimal #75

aymkhalil opened this issue Jun 20, 2023 · 0 comments

Comments

@aymkhalil
Copy link
Collaborator

In order to deal to support use cases where a decimal value has to be downscaled to fit into existing decimal schema with a certain scale, it is useful to allow users to downscale there decimals. The propose is to add a function with the following signature:

decimalFromNumberWithScale(decimal, scale)

For more context about why such method is needed, check the example below:
Given the following schema

{
        "name": "v2",
        "type": [
          "null",
          {
            "type": "bytes",
            "logicalType": "decimal",
            "precision": 4,
            "scale": 3
          }
        ]
}

The user can send a deceased scale value like 1.3, however increasing the scale by sending a value like 1.33499 would fail with

org.apache.avro.AvroTypeException: Cannot encode decimal with scale 5 as scale 3 without rounding in field v2

(for more details, check: #69 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant