hi! for 1st query: I am trying aggregate a value ...
# troubleshooting
k
hi! for 1st query: I am trying aggregate a value on a 10 second hop window and in UDF there would be some condition before aggregation but while access
window_start
in UDF but it gives the bellow error, of Unsupported call for 2nd query while using 2nd query it does not generate any result, not sure whats wrong but it works fine with ADD(value) 1st query
Copy code
SELECT
  HOP_START(time_ltz, INTERVAL '5' SECOND, INTERVAL '10' SECOND) as window_start,
  HOP_END(time_ltz, INTERVAL '5' SECOND, INTERVAL '10' SECOND) as window_end,
  ADD(value, HOP_START(time_ltz, INTERVAL '5' SECOND, INTERVAL '10' SECOND)) as aggSum 
FROM Log
GROUP BY HOP(time_ltz, INTERVAL '5' SECOND, INTERVAL '10' SECOND)
2nd query
Copy code
SELECT window_start, window_end, ADD(value, window_start) FROM
TABLE(HOP(TABLE Log, DESCRIPTOR(time_ltz), INTERVAL '5' SECOND, INTERVAL '10' SECOND))
WHERE TO_TIMESTAMP(`timestamp`) <= (window_end - INTERVAL '5' SECOND)
GROUP BY window_start, window_end
Copy code
public class Add extends AggregateFunction<Integer, AddAccumulator> {

    @Override
    public Integer getValue(AddAccumulator accumulator) {
        return accumulator.getSum();
    }

    @Override
    public AddAccumulator createAccumulator() {
        return new AddAccumulator();
    }

    public void accumulate(AddAccumulator acc, Integer iValue, LocalDateTime window_start) {
        // some condition on window_start before aggregate iValue

        if(iValue == null) return;
        acc.setSum(iValue);

    }

    public void retract(AddAccumulator acc, Integer iValue) {
        acc.setSum(acc.getSum() - iValue);
    }

    public void merge(AddAccumulator acc, Iterable<AddAccumulator> it) {
        for (AddAccumulator a : it) {
            acc.setSum(acc.getSum() + a.getSum());
        }
    }

    public void resetAccumulator(AddAccumulator acc) {
        acc.setSum(0);
    }

}
Copy code
Exception in thread "main" org.example.exceptions.SQLParseException: Error in executing SQL query
	at org.example.StaticRuleEvaluator.main(StaticRuleEvaluator.java:158)
Caused by: org.apache.flink.table.planner.codegen.CodeGenException: Unsupported call: HOP_START(TIMESTAMP_LTZ(3), INTERVAL SECOND(3) NOT NULL, INTERVAL SECOND(3) NOT NULL) 
If you think this function should be supported, you can create an issue and start a discussion for it.
	at org.apache.flink.table.planner.codegen.ExprCodeGenerator.$anonfun$generateCallExpression$10(ExprCodeGenerator.scala:846)
	at scala.Option.getOrElse(Option.scala:121)
	at org.apache.flink.table.planner.codegen.ExprCodeGenerator.$anonfun$generateCallExpression$8(ExprCodeGenerator.scala:842)
	at scala.Option.getOrElse(Option.scala:121)
	at org.apache.flink.table.planner.codegen.ExprCodeGenerator.generateCallExpression(ExprCodeGenerator.scala:847)
	at org.apache.flink.table.planner.codegen.ExprCodeGenerator.visitCall(ExprCodeGenerator.scala:490)
	at org.apache.flink.table.planner.codegen.ExprCodeGenerator.visitCall(ExprCodeGenerator.scala:57)
	at org.apache.calcite.rex.RexCall.accept(RexCall.java:189)