flink自定义函数未找到匹配项

lymnna71  于 2021-06-21  发布在  Flink
关注(0)|答案(0)|浏览(1245)

我编写了一个本地解析json的方法,可以在idea中执行,但是当我将它编译成jar包并使用flink run执行它时,它会提示 tNo match found for function signature get_json_object(<CHARACTER>, <CHARACTER>) 我使用的flink版本是1.11。
下面是我的代码程序:

public class MarketMonitorHiveJob {
    public static void main(String[] args) throws IOException {

        ParameterToolFactory parameterToolFactory = new ParameterToolFactory();
        ParameterTool parameterTool = parameterToolFactory.createParameterTool();

        EnvironmentSettings settings = EnvironmentSettings.newInstance()
                .useBlinkPlanner()
                .inBatchMode()
                .build();

        TableEnvironment tableEnv =
                TableEnvironment.create(settings);

        tableEnv.getConfig().setSqlDialect(SqlDialect.HIVE);

        // The function can be found in IDEA, but cannot be found after compilation
        tableEnv.createTemporarySystemFunction("get_json_object", new UdfJson());

        HiveCatalog hiveCatalog = new HiveCatalog(CataLogEnum.HERMES.getCataLogName(),
                CataLogEnum.HERMES.getDbName(),
                parameterTool.get(FlinkProperEnum.FLINK_HIVE_CONF_DIR.key));

        tableEnv.registerCatalog(CataLogEnum.HERMES.getCataLogName(), hiveCatalog);
        tableEnv.useCatalog(CataLogEnum.HERMES.getCataLogName());

        SQLBase marketMonitorHiveBaseSQL = new MarketMonitorHiveBaseSQL();
        String hiveBaseSQL = marketMonitorHiveBaseSQL.getSqlTemplate("2020-06-20", "2020-06-20", "2020-06-20");

        System.out.println(hiveBaseSQL);
        tableEnv.executeSql(hiveBaseSQL);

       // ...more
    }
}
public class UdfJson extends ScalarFunction {
  public String eval(String jsonString, String pathString) {
    //... more
  }
}

具体错误信息如下

Caused by: org.apache.calcite.sql.validate.SqlValidatorException: No match found for function signature get_json_object(<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)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题