问题描述
我编写了一种在本地解析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)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)