How to visit outer service in batch for sql

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to visit outer service in batch for sql

liujiangang
      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.