You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by 刘建刚 <li...@gmail.com> on 2020/08/26 12:02:04 UTC

How to visit outer service in batch for sql

      For API, we can visit outer service in batch through countWindow,
such as the following. We can visit outer service every 1000 records. If we
visit outer service every record, it will be very slow for our job.

source.keyBy(new KeySelector())
        .countWindow(1000)
        .apply((WindowFunction<MyType, MyType, String, GlobalWindow>)
                (s, globalWindow, values, collector) -> {
            List<MyType> resultList = service.visit(values);
            for (MyType result: resultList) {
                if (result.ok) {
                    collector.collect(result);
                }
            }
        });

      But how can I write SQL to implement the batch logic? I can use udf
to visit outer service. Currently, Flink only support time window but not
count window. I also check the udf wiki but find it hard to batch records.
      Any suggestion is welcome. Thank you.

Re: How to visit outer service in batch for sql

Posted by Danny Chan <yu...@gmail.com>.
Hi, did you try to define a UDAF there within your group window sql, where you can have a custom service there.

I’m afraid you are right, SQL only supports time windows.

Best,
Danny Chan
在 2020年8月26日 +0800 PM8:02,刘建刚 <li...@gmail.com>,写道:
>       For API, we can visit outer service in batch through countWindow, such as the following. We can visit outer service every 1000 records. If we visit outer service every record, it will be very slow for our job.
> source.keyBy(new KeySelector())
>        .countWindow(1000)
>        .apply((WindowFunction<MyType, MyType, String, GlobalWindow>)
>                (s, globalWindow, values, collector) -> {
>            List<MyType> resultList = service.visit(values);
>            for (MyType result: resultList) {
>                if (result.ok) {
>                    collector.collect(result);
>                }
>            }
>        });
>       But how can I write SQL to implement the batch logic? I can use udf to visit outer service. Currently, Flink only support time window but not count window. I also check the udf wiki but find it hard to batch records.
>       Any suggestion is welcome. Thank you.
>
>
>
>
>
>