Hi,all:
我在使用flinksql1.11连接hive做计算和转换时,遇到了找不到已注册的UDAF,这是我UDAF代码的问题,还是数据类型的问题,还是bug呢?请各位大佬赐教_(:з」∠)_ >以下是相关代码: ----------------------------------------------------------------------------------------------------------------- public class Product0 { public Double prod = 1D; } public class ProductUdaf0 extends AggregateFunction<Double, Product0> { @Override public Product0 createAccumulator() { return new Product0(); } @Override @DataTypeHint("DOUBLE") public Double getValue(Product0 acc) { return acc.prod; } public void accumulate(Product0 acc, Double iValue) { acc.prod *= iValue; } public void retract(Product0 acc, Double iValue) { acc.prod /= iValue; } public void merge(Product0 acc, Iterable<Product0> it) { for (Product0 p : it) { accumulate(acc, p.prod); } } public void resetAccumulator(Product0 acc) { acc.prod = 1D; } } ...tableEnv.createTemporarySystemFunction("prod", ProductUdaf0.class); Table resultTable = tableEnv.sqlQuery("select pf_id,prod(yldrate+1)-1 as yldrate from queryData group by pf_id");... >以下是相关堆栈信息: ----------------------------------------------------------------------------------------------------------------- ... Caused by: org.apache.flink.table.api.ValidationException: SQL validation failed. From line 1, column 14 to line 1, column 28: No match found for function signature prod(<NUMERIC>) at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:146) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:108) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:185) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:78) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.api.internal.TableEnvironmentImpl.sqlQuery(TableEnvironmentImpl.java:664) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at com.yss.datamiddle.flinksql.index.TimeWeightedReturnP.calculate(TimeWeightedReturnP.java:25) ~[flinksql_0223.jar:?] ... 21 more Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, column 14 to line 1, column 28: No match found for function signature prod(<NUMERIC>) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_201] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_201] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_201] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_201] at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:457) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:839) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:824) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5089) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1882) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:305) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:218) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5858) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5845) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1800) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1785) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.type.InferTypes.lambda$static$0(InferTypes.java:46) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.inferUnknownTypes(SqlValidatorImpl.java:1980) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.inferUnknownTypes(SqlValidatorImpl.java:1968) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:479) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4255) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3523) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1110) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1084) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:232) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1059) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:766) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:141) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:108) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:185) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:78) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.api.internal.TableEnvironmentImpl.sqlQuery(TableEnvironmentImpl.java:664) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at com.yss.datamiddle.flinksql.index.TimeWeightedReturnP.calculate(TimeWeightedReturnP.java:25) ~[flinksql_0223.jar:?] ... 21 more Caused by: org.apache.calcite.sql.validate.SqlValidatorException: No match found for function signature prod(<NUMERIC>) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_201] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_201] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_201] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_201] at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:457) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:550) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:839) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:824) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5089) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1882) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:305) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:218) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5858) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5845) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1800) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1785) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.type.InferTypes.lambda$static$0(InferTypes.java:46) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.inferUnknownTypes(SqlValidatorImpl.java:1980) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.inferUnknownTypes(SqlValidatorImpl.java:1968) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:479) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4255) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3523) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1110) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1084) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:232) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1059) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:766) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:141) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:108) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:185) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:78) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at org.apache.flink.table.api.internal.TableEnvironmentImpl.sqlQuery(TableEnvironmentImpl.java:664) ~[flink-table-blink_2.12-1.11.1.jar:1.11.1] at com.yss.datamiddle.flinksql.index.TimeWeightedReturnP.calculate(TimeWeightedReturnP.java:25) ~[flinksql_0223.jar:?] ... Best tianlulu 2021.2.24 |
Free forum by Nabble | Edit this page |