Hi Spencer,
I believe precision and scale from the Avro specification have their
origins from DBMS/SQL systems (at least that where I first learned these
definitions).

Precision is the maximum number of decimal digits that the decimal should
represent.  (generally it only makes sense to represent numbers with at
least 1 digit, hence the positive constraint).

Scale is the fixed number of fractional digits (the ones to the right of
the decimal place). (can range from 0 if no fraction is desired to
precision).

-Micah

On Thu, Mar 4, 2021 at 6:03 PM Spencer Nelson <[email protected]> wrote:

> The current (1.10.1) Avro spec is a little light on explanation for
> the decimal logical type:
> https://avro.apache.org/docs/1.10.1/spec.html#Decimal.
>
> It says "scale" is "a JSON integer representing the scale," and
> "precision" is "a JSON integer representing the (maximum) precision of
> decimals stored in this type."
>
> Scale is further specified to be non-negative, and precision is positive.
>
> What are the precision and scale required to represent a decimal like
> "1.234E10?" I would think that has a scale of 10 and a precision of 4.
> But from perusing code, it appears that this would be treated as a
> decimal with a scale of 0, and a precision of 10, which seems quite
> far off! If I'm right about that (and I might not be!), then why is a
> scale strictly non-negative, and why are all the meaningless zeroes
> included in describing "precision?"
>

Reply via email to