Re: The way to write a UDF with generic type

Posted by Timo Walther on
URL: http://deprecated-apache-flink-user-mailing-list-archive.369.s1.nabble.com/The-way-to-write-a-UDF-with-generic-type-tp25329p25374.html

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, 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 to write a class
> which extends AggregateFunction *with generic type* to implement the max
> function.
>
> Then I want to register only one function name for all types.
> E.g.
> tableEnv.registerFunction("MYMAX", new MyMax());
> instead of
> tableEnv.registerFunction("MYINTEGERMAX", new MyIntegerMax());
> tableEnv.registerFunction("MYLONGMAX", new MyLongMax());
> tableEnv.registerFunction("MYDOULBEMAX", new MyDoubleMax());
>
> Is there a way to implement that?
> I know the build in function "MAX" can apply to all types, so I wonder if I
> can also implement that.
> Thanks.
>
>
>
> --
> Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/