Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-18520

New Table Function type inference fails

    XMLWordPrintableJSON

Details

    Description

      For a simple UDTF likeĀ 

      public class Split extends TableFunction<String> {
      		public Split(){}
      		public void eval(String str, String ch) {
      			if (str == null || str.isEmpty()) {
      				return;
      			} else {
      				String[] ss = str.split(ch);
      				for (String s : ss) {
      					collect(s);
      				}
      			}
      		}
      	}
      

      register it using new function type inference tableEnv.createFunction("my_split", Split.class); and using it in a simple query will fail with following exception:

      Exception in thread "main" org.apache.flink.table.api.ValidationException: SQL validation failed. From line 1, column 93 to line 1, column 115: No match found for function signature my_split(<CHARACTER>, <CHARACTER>)
      	at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:146)
      	at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:108)
      	at org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:187)
      	at org.apache.flink.table.planner.operations.SqlToOperationConverter.convertSqlInsert(SqlToOperationConverter.java:527)
      	at org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:204)
      	at org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:78)
      	at org.apache.flink.table.api.internal.TableEnvironmentImpl.sqlUpdate(TableEnvironmentImpl.java:716)
      	at com.bytedance.demo.SqlTest.main(SqlTest.java:64)
      Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, column 93 to line 1, column 115: No match found for function signature my_split(<CHARACTER>, <CHARACTER>)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:457)
      	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:839)
      	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:824)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5089)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1882)
      	at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:305)
      	at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:218)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5858)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5845)
      	at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1800)
      	at org.apache.calcite.sql.validate.ProcedureNamespace.validateImpl(ProcedureNamespace.java:57)
      	at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1110)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1084)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3256)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3238)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateJoin(SqlValidatorImpl.java:3303)
      	at org.apache.flink.table.planner.calcite.FlinkCalciteSqlValidator.validateJoin(FlinkCalciteSqlValidator.java:86)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3247)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3510)
      	at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
      	at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1110)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1084)
      	at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:232)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1059)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:766)
      	at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:141)
      	... 7 more
      Caused by: org.apache.calcite.sql.validate.SqlValidatorException: No match found for function signature my_split(<CHARACTER>, <CHARACTER>)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:457)
      	at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:550)
      	... 35 more
      

      it's reported from user-zh: http://apache-flink.147419.n8.nabble.com/Flink-1-11-SQL-UDTF-No-match-found-for-function-signature-td4553.html
      CC twalthr

      Attachments

        Issue Links

          Activity

            People

              twalthr Timo Walther
              libenchao Benchao Li
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: