Feng Zhu created CALCITE-3332: --------------------------------- Summary: Query failed with AssertionError: cannot cast null as class java.math.BigDecimal Key: CALCITE-3332 URL: https://issues.apache.org/jira/browse/CALCITE-3332 Project: Calcite Issue Type: Bug Components: core Affects Versions: 1.21.0 Reporter: Feng Zhu
The problem can be reproduced by the following test case in ReflectiveSchemaTest {code:java} @Test public void testDivideNull() { final CalciteAssert.AssertThat with = CalciteAssert.that().withSchema("s", CATCHALL); with.query("select \"wrapperLong\" / null as c\n" + " from \"s\".\"everyTypes\"") .runs(); }{code} The stacktrace is {code:java} java.lang.AssertionError: cannot cast null as class java.math.BigDecimal at org.apache.calcite.sql.SqlLiteral.getValueAs(SqlLiteral.java:351) at org.apache.calcite.sql.SqlCallBinding.getOperandLiteralValue(SqlCallBinding.java:217) at org.apache.calcite.sql.SqlBinaryOperator.getMonotonicity(SqlBinaryOperator.java:190) at org.apache.calcite.sql.SqlCall.getMonotonicity(SqlCall.java:182) at org.apache.calcite.sql.SqlCallBinding.getOperandMonotonicity(SqlCallBinding.java:188) at org.apache.calcite.sql.SqlAsOperator.getMonotonicity(SqlAsOperator.java:139) at org.apache.calcite.sql.SqlCall.getMonotonicity(SqlCall.java:182) at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectList(SqlToRelConverter.java:3961) at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:670) at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:627) at org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3180) at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:563) {code} When SqlBinaryOperator figuring out its {{Monotonicity}}, if the second operand is a Literal, it will cast the literal into BigDecimal. But the {{Null}} Literal can not be properly handled. -- This message was sent by Atlassian Jira (v8.3.2#803003)