????????????????????????????????????????????_(:??????)_



------------------ ???????? ------------------
??????:                                                                         
                                               "user-zh"                        
                                                            
<chenye...@163.com&gt;;
????????:&nbsp;2021??2??22??(??????) ????11:14
??????:&nbsp;"user-zh"<user-zh@flink.apache.org&gt;;

????:&nbsp;Re:Re:SqlValidatorException: No match found for function signature 
prod(<NUMERIC&gt;)



??????????scalaFunction ?

















?? 2021-02-22 10:25:31??"xiaoyue" <18242988...@163.com&gt; ??????
&gt;?????????????????????????????? _(:??????)_
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;?? 2021-02-20 13:14:18??"xiaoyue" <18242988...@163.com&gt; ??????
&gt;
&gt;????????flinksql1.11??udaf??????SqlValidatorException: No match found for 
function signature prod(<NUMERIC&gt;)??????????????????_(:??????)_
&gt;
&gt;????????????
&gt;-----------------------------------------------------
&gt;...
&gt;&nbsp; stableEnv.createTemporarySystemFunction("prod", 
ProductAggregateFunction.class);
&gt;&nbsp; Table resultTable = stableEnv.sqlQuery("select 
pf_id,prod(yldrate+1)-1 as yldrate from queryData group by pf_id");
&gt;...
&gt;-----------------------------------------------------
&gt;@FunctionHint(
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; input = @DataTypeHint("Double"),
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; output = @DataTypeHint("Double")
&gt;)
&gt;public class ProductAggregateFunction extends AggregateFunction<Double, 
Product&gt; {
&gt;
&gt;
&gt;&nbsp;&nbsp;&nbsp; @Override
&gt;&nbsp;&nbsp;&nbsp; public Double getValue(Product acc) {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return acc.prod;
&gt;&nbsp;&nbsp;&nbsp; }
&gt;&nbsp;&nbsp;&nbsp; @Override
&gt;&nbsp;&nbsp;&nbsp; public Product createAccumulator() {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new Product();
&gt;&nbsp;&nbsp;&nbsp; }
&gt;&nbsp;&nbsp;&nbsp; public void accumulate(Product acc, Double iValue) {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acc.prod *= iValue;
&gt;&nbsp;&nbsp;&nbsp; }
&gt;&nbsp;&nbsp;&nbsp; public void retract(Product acc, Double iValue) {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acc.prod /= iValue;
&gt;&nbsp;&nbsp;&nbsp; }
&gt;&nbsp;&nbsp;&nbsp; public void merge(Product acc, Iterable<Product&gt; it) {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (Product p : it) {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
accumulate(acc, p.prod);
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&gt;&nbsp;&nbsp;&nbsp; }
&gt;&nbsp;&nbsp;&nbsp; public void resetAccumulator(Product acc) {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acc.prod = 1D;
&gt;&nbsp;&nbsp;&nbsp; }
&gt;}
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;

回复