zaiin
2021-07-07 12:51
采纳率: 100%
浏览 91
已结题

Flink sql :找不到 instr 函数的匹配项

题目写不下,完整报错见文字下面:No match found for function signature instr (, )

tEnv.executeSql("select cast(substr(pay,instr(pay,'-')+1,2) as int) from lie").print();

字段是这样的 举几行示例 字段是薪资
pay
15-16薪
9-13薪

tEnv.executeSql("select instr(pay,'-') from lie").print();

开头的查询语句报的题目上的错,就算是单独的‘select instr(pay,'-') from xxx’都不能运行。去网上搜只搜到一个阿里云的网页说instr函数只支持blink2.2及以上,关键是这个语句复制给给同桌电脑上能运行,我把仓库相关jar包删除了重新下载依赖,还是一直报“No match found for function signature instr”。
刚入门小白求大大大佬解答,这问题卡了我几天了 TAT

相关pom依赖 flink version是1.13

<dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-table-planner_2.11</artifactId>
            <version>${flink.version}</version>
</dependency>
<dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-table-planner-blink_2.11</artifactId>
            <version>${flink.version}</version>
</dependency>

报错:

Exception in thread "main" org.apache.flink.table.api.ValidationException: SQL validation failed. From line 1, column 8 to line 1, column 21: No match found for function signature instr(<CHARACTER>, <CHARACTER>)
    at org.apache.flink.table.calcite.FlinkPlannerImpl.validateInternal(FlinkPlannerImpl.scala:147)
    at org.apache.flink.table.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:107)
    at org.apache.flink.table.sqlexec.SqlToOperationConverter.convert(SqlToOperationConverter.java:151)
    at org.apache.flink.table.planner.ParserImpl.parse(ParserImpl.java:89)
    at org.apache.flink.table.api.internal.TableEnvImpl.executeSql(TableEnvImpl.scala:570)
    at com.zzy.Test_01.main(Test_01.java:112)
Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to line 1, column 21: No match found for function signature instr(<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:467)
    at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:883)
    at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:868)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4860)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1813)
    at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:321)
    at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:226)
    at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5709)
    at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5696)
    at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1735)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1726)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:420)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4060)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3346)
    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:996)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:974)
    at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:232)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:951)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:703)
    at org.apache.flink.table.calcite.FlinkPlannerImpl.validateInternal(FlinkPlannerImpl.scala:142)
    ... 5 more
Caused by: org.apache.calcite.sql.validate.SqlValidatorException: No match found for function signature instr(<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:467)
    at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:560)
    ... 27 more
  • 收藏

1条回答 默认 最新

  • CSDN专家-sinjack 2021-07-07 13:05
    已采纳

    看报错提示:No match found for function signature instr (, )
    你是不是用了中文下的逗号。

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题