You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2019/09/09 20:04:00 UTC

[jira] [Commented] (CALCITE-3332) Query failed with AssertionError: cannot cast null as class java.math.BigDecimal

    [ https://issues.apache.org/jira/browse/CALCITE-3332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16926063#comment-16926063 ] 

Julian Hyde commented on CALCITE-3332:
--------------------------------------

The javadoc for {{getOperandLiteralValue}} does not spell out what should happen if the operand is the null literal. Let's resolve that.

> 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
>            Assignee: Feng Zhu
>            Priority: Major
>
> 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 is not properly handled.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)