Aleksandr Efimov created CALCITE-7844:
-----------------------------------------

             Summary: Decimal division scale reduction uses total precision 
instead of integral digits
                 Key: CALCITE-7844
                 URL: https://issues.apache.org/jira/browse/CALCITE-7844
             Project: Calcite
          Issue Type: Bug
            Reporter: Aleksandr Efimov


With a custom type system allowing precision and scale 38, DECIMAL(18,6) / 
DECIMAL(18,6) returns DECIMAL(38,6). The documented algorithm implies 
DECIMAL(38,20).

In RelDataTypeSystem.deriveDecimalDivideType, the scale-reduction condition 
compares total precision with the bound instead of integral digits.

Reproduced on main c425a5fa0; the same condition exists in 1.42.0. Related: 
CALCITE-6464.

Correcting the condition also changes default inferred types: 95.0 / 100 
becomes DECIMAL(14,12) instead of DECIMAL(14,6). Incorrect numeric values have 
not been demonstrated.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to