Re: The way to write a UDF with generic type

2019-01-08 Thread yinhua.dai
Get it, thanks. -- Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/

Re: The way to write a UDF with generic type

2019-01-08 Thread Timo Walther
Currently, this functionality is hard-coded in the aggregation translation. Namely in `org.apache.flink.table.runtime.aggregate.AggregateUtil#transformToAggregateFunctions` [1]. Timo [1] https://github.com/apache/flink/blob/master/flink-libraries/flink-table/src/main/scala/org/apache/flink/t

Re: The way to write a UDF with generic type

2019-01-07 Thread yinhua.dai
Hi Timo, Can you let me know how the build-in "MAX" function able to support different types? Thanks. -- Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/

Re: The way to write a UDF with generic type

2019-01-07 Thread Timo Walther
Currently, there is no more flexible approch for aggregate functions. Scalar functions can be overloaded but aggregate functions do not support this so far. Regards, Timo Am 07.01.19 um 02:27 schrieb yinhua.dai: Hi Timo, But getResultType should only return a concrete type information, righ

Re: The way to write a UDF with generic type

2019-01-06 Thread yinhua.dai
Hi Timo, But getResultType should only return a concrete type information, right? How could I implement with a generic type? I'd like to clarify my questions again. Say I want to implement my own "MAX" function, but I want to apply it to different types, e.g. integer, long, double etc, so I tried

Re: The way to write a UDF with generic type

2019-01-04 Thread Timo Walther
Hi Yinhua, Flink needs to know how to serialize and deserialize a type `T`. If you are using a type variable here, Flink can not derive the type information. You need to override org.apache.flink.table.functions.AggregateFunction#getResultType and return type information that matches. Rega

Re: The way to write a UDF with generic type

2019-01-04 Thread yinhua.dai
Hi Chesnay, Maybe you misunderstand my question. I have below code: public class MyMaxAggregation extends AggregateFunction { @Override public MyAccumulator createAccumulator() { return new MyAccumulator(); } @Override public T getValue(MyAccumulator accumulator) { return null;

Re: The way to write a UDF with generic type

2019-01-04 Thread Chesnay Schepler
I believe you have to extend "org.apache.flink.table.functions.AggregateFunction" instead for it to work with SQL (or more generally speaking, any sub-class of "org.apache.flink.table.functions.UserDefinedFunction". On 04.01.2019 05:18, yinhua.dai wrote: Hi Community, I tried to write a UDF

The way to write a UDF with generic type

2019-01-03 Thread yinhua.dai
Hi Community, I tried to write a UDF with generic type, but seems that Flink will complain not recognizing the type information when I use it in SQL. I checked the implementation of native function "MAX" and realize that it's not using the same API(AggregationFunction e.g.) as user defined functi