You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "luoyuxia (Jira)" <ji...@apache.org> on 2022/03/23 12:25:00 UTC
[jira] [Created] (FLINK-26829) ClassCastException will be thrown when the second operand of divide is a function call
luoyuxia created FLINK-26829:
--------------------------------
Summary: ClassCastException will be thrown when the second operand of divide is a function call
Key: FLINK-26829
URL: https://issues.apache.org/jira/browse/FLINK-26829
Project: Flink
Issue Type: Bug
Components: Table SQL / Planner
Affects Versions: 1.15.0
Reporter: luoyuxia
Fix For: 1.16.0
Can be reproduced by add the following code in SqlExpressionTest#testDivideFunctions
{code:java}
testExpectedSqlException(
"1/POWER(5, 5)", divisorZeroException, classOf[ArithmeticException]) {code}
Then the method ExpressionReducer#skipAndValidateExprs will throw the exception:
{code:java}
java.lang.ClassCastException: org.apache.calcite.rex.RexCall cannot be cast to org.apache.calcite.rex.RexLiteral {code}
The following code will cast the DEVIDE's second op to RexLiteral, but it maybe a function call.
{code:java}
// according to BuiltInFunctionDefinitions, the DEVIDE's second op must be numeric
assert(RexUtil.isDeterministic(divisionLiteral))
val divisionComparable = {
divisionLiteral.asInstanceOf[RexLiteral].getValue.asInstanceOf[Comparable[Any]]
} {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)