[ https://issues.apache.org/jira/browse/FLINK-27247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17522367#comment-17522367 ]
Marios Trivyzas commented on FLINK-27247: ----------------------------------------- Commented on the PR as well, I think we need to fix the root of the issue which is the implicit cast introduced to cast from a nullable to a not nullable type, and not just allow this in the code gen. > ScalarOperatorGens.numericCasting is not compatible with legacy behavior > ------------------------------------------------------------------------ > > Key: FLINK-27247 > URL: https://issues.apache.org/jira/browse/FLINK-27247 > Project: Flink > Issue Type: Bug > Components: Table SQL / Planner > Reporter: xuyang > Priority: Minor > Labels: pull-request-available > > Add the following test cases in ScalarFunctionsTest: > {code:java} > // code placeholder > @Test > def test(): Unit ={ > testSqlApi("rand(1) + 1","") > } {code} > it will throw the following exception: > {code:java} > // code placeholder > org.apache.flink.table.planner.codegen.CodeGenException: Unsupported casting > from DOUBLE to DOUBLE NOT NULL. > at > org.apache.flink.table.planner.codegen.calls.ScalarOperatorGens$.numericCasting(ScalarOperatorGens.scala:1734) > at > org.apache.flink.table.planner.codegen.calls.ScalarOperatorGens$.generateBinaryArithmeticOperator(ScalarOperatorGens.scala:85) > at > org.apache.flink.table.planner.codegen.ExprCodeGenerator.generateCallExpression(ExprCodeGenerator.scala:507) > at > org.apache.flink.table.planner.codegen.ExprCodeGenerator.visitCall(ExprCodeGenerator.scala:481) > at > org.apache.flink.table.planner.codegen.ExprCodeGenerator.visitCall(ExprCodeGenerator.scala:57) > at org.apache.calcite.rex.RexCall.accept(RexCall.java:174) > at > org.apache.flink.table.planner.codegen.ExprCodeGenerator.$anonfun$visitCall$1(ExprCodeGenerator.scala:478) > at > scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:233) > at > scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:58) > at > scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:51) > at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47) > at scala.collection.TraversableLike.map(TraversableLike.scala:233) > at scala.collection.TraversableLike.map$(TraversableLike.scala:226) > at scala.collection.AbstractTraversable.map(Traversable.scala:104) > at > org.apache.flink.table.planner.codegen.ExprCodeGenerator.visitCall(ExprCodeGenerator.scala:469) > ... {code} > This is because in ScalarOperatorGens#numericCasting, FLINK-24779 lost the > logic that in some cases there is no need to casting the left and right type. -- This message was sent by Atlassian Jira (v8.20.1#820001)