DonnyZone commented on a change in pull request #1381: [CALCITE-3245]
CompileException in Janino when a query contains a division between a Double
and a BigDecimal
URL: https://github.com/apache/calcite/pull/1381#discussion_r314673744
##########
File path:
core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactoryImpl.java
##########
@@ -546,6 +546,33 @@ public boolean isNullable() {
return nullable;
}
+ public int getPrecision() {
+ final SqlTypeName typeName =
+ JavaToSqlTypeConversionRules.instance().lookup(clazz);
+ if (typeName != null) {
+ return typeSystem.getDefaultPrecision(typeName);
+ }
+ return PRECISION_NOT_SPECIFIED;
+ }
+
+ public int getScale() {
+ final SqlTypeName typeName =
Review comment:
If there are some operands with Decimal types in RexCall, its return type is
Decimal, and the validator will calculate the result's precision and scale
during inferring return type.
However, as we can see in **everyTypes**, when the column is a reflected
JavaType(BigDecimal), its `(precision, scale)=(PRECISION_NOT_SPECIFIED,
SCALE_NOT_SPECIFIED) = (-1, Integer.MIN_VALUE)`.
During the calculation for the return type's precision and scale in
`RelDataTypeSystem.deriveDecimalPlusType`, it leads to Assertions (e.g.,
`assert precision > 0`).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services