Fix precision and scale inference for aggregate rewriting in Calcite
This change fixes an issue where type inference of intermediate precision and scale for division is not correct.
Before upgrade to CDP 7.1.8 CHF2
The AggregateReduceFunctionsRule
class of Calcite rules reduce aggregate
functions into simpler forms, for example, avg(x) into sum(x)/count(x). When the type of avg(x)
aggregate function is decimal, type inference of the intermediate precision and scale for the
division is not done correctly.
The reason is due to lack of support for some types in the getDefaultPrecision
method in HiveTypeSystemImpl
.
After upgrade to CDP 7.1.8 CHF2
HIVE-22978 provides the fix to correct the precision and scale type inference for
aggregate rewriting in Calcite. Additionally, the deriveSumType
method in
HiveTypeSystemImpl
is overridden to abide by the Hive semantics for sum
aggregate type inference.