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

2022-10-28 Thread Jiajun Xie (Jira)


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

Jiajun Xie commented on CALCITE-3332:
-

The issue has been fixed in 
[7df9bba6|[https://github.com/apache/calcite/commit/7df9bba657924b37c5b55a480b13215ba0326707],]
 so I close it.

> 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
>  Labels: pull-request-available
>  Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> 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.20.10#820010)


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

2019-09-10 Thread jin xing (Jira)


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

jin xing commented on CALCITE-3332:
---

Thanks ~ [~donnyzone]

I left minor comments on the PR and please check if they are valid.

> 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
>  Labels: pull-request-available
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> 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)


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

2019-09-09 Thread Julian Hyde (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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)