Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.35.0
Description
Adding the following test to RelToSqlConverterTest produces an AssertionFailure:
@Test void testNumericScaleMod() { final String sql = "SELECT MOD(CAST(2 AS DECIMAL(39, 20)), 2)"; final String expected = ""; sql(sql).withPostgresqlModifiedDecimalTypeSystem() .ok(expected); }
The exception is here:
java.lang.AssertionError
at org.apache.calcite.rel.type.RelDataTypeSystem.deriveDecimalModType(RelDataTypeSystem.java:383)
at org.apache.calcite.sql.type.ReturnTypes.lambda$static$11(ReturnTypes.java:849)
at org.apache.calcite.sql.type.SqlTypeTransformCascade.inferReturnType(SqlTypeTransformCascade.java:58)
at org.apache.calcite.sql.type.SqlReturnTypeInferenceChain.inferReturnType(SqlReturnTypeInferenceChain.java:55)
In this line:
int scale = Math.max(s1, s2); assert scale <= getMaxNumericScale();
I suspect that doing a Math.min with the getMaxNumericScale (instead of an Assert) is sufficient to fix this particular problem. The question is whether the compiler should really enforce the invariant that this assertion checks.
Attachments
Issue Links
- links to