Jark Wu created FLINK-4962: ------------------------------ Summary: Improve exception information about operand type inference failed in UDF SQL validation Key: FLINK-4962 URL: https://issues.apache.org/jira/browse/FLINK-4962 Project: Flink Issue Type: Improvement Reporter: Jark Wu Priority: Minor
In the SQL validation phase, the custom scalar function 's operand types will be checked. If there is no corresponding signature , an exception will be thrown, but the exception message is unclear. For example: {code} object Func13 extends ScalarFunction { def eval(a: Double): String = { s"$a" } } tEnv.registerFunction("Func13", Func13) tEnv.sql("SELECT Func13(1.1) FROM MyTable") {code} and it throws {code} Disconnected from the target VM, address: '127.0.0.1:63497', transport: 'socket' org.apache.flink.api.table.ValidationException: SQL validation failed. Operand types of could not be inferred. at org.apache.flink.api.table.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:91) at org.apache.flink.api.table.expressions.utils.ExpressionTestBase.addSqlTestExpr(ExpressionTestBase.scala:140) at org.apache.flink.api.table.expressions.utils.ExpressionTestBase.testSqlApi(ExpressionTestBase.scala:208) at org.apache.flink.api.table.expressions.UserDefinedScalarFunctionTest.testResults(UserDefinedScalarFunctionTest.scala:114) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84) Caused by: org.apache.flink.api.table.ValidationException: Operand types of could not be inferred. at org.apache.flink.api.table.functions.utils.ScalarSqlFunction$$anon$2$$anonfun$2.apply(ScalarSqlFunction.scala:108) at org.apache.flink.api.table.functions.utils.ScalarSqlFunction$$anon$2$$anonfun$2.apply(ScalarSqlFunction.scala:108) at scala.Option.getOrElse(Option.scala:120) at org.apache.flink.api.table.functions.utils.ScalarSqlFunction$$anon$2.inferOperandTypes(ScalarSqlFunction.scala:108) at org.apache.calcite.sql.validate.SqlValidatorImpl.inferUnknownTypes(SqlValidatorImpl.java:1659) at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:427) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:3549) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3052) at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60) at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:86) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:865) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:846) at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:208) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:821) at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:532) at org.apache.flink.api.table.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:87) ... 27 more {code} I hope it could express more information about the actual and expected operand types. The {{ScalarSqlFunction.createOperandTypeInference}} should be touched. -- This message was sent by Atlassian JIRA (v6.3.4#6332)