I am trying to use User defined Table Aggregate function directly in the SQL 
so that I could combine all the rows collected in a window into one object.

GIVEN a User defined Table Aggregate function

public class MyUDTAGG extends 
TableAggregateFunction<PurchaseWindow,PurchaseWindow> {

        public PurchaseWindow createAccumulator() {
                return new PurchaseWindow();
        }

        public void accumulate(PurchaseWindow acc, String name, double cost) {
                acc.add(name, cost);
        }

        public void emitValue(PurchaseWindow acc, Collector<PurchaseWindow> 
out) {
                out.collect(acc);
        }
}

THAT it is registered as

StreamTableEnvironment tEnv = ...
tEnv.registerFunction("MyUDTAGG", new MyUDTAGG());

THEN is it possible to call it in an SQL query in this manner?

SELECT MyUDTAGG(name, SUM(cost)) AS purchase_window
FROM purchases
GROUP BY TUMBLE(proactive, INTERVAL '1' DAY), name


I am receiving an SQL validation error, "No match found for function signature 
...".

What am I doing wrong, or is there a better way to do this?



Reply via email to