apache-flink Table API Using external sinks


A Table can be written to a TableSink, which is a generic interface to support different formats and file systems. A batch Table can only be written to a BatchTableSink, while a streaming table requires a StreamTableSink.

Currently, flink offers only the CsvTableSink interface.


In the examples above, replace:

DataSet<Row> result = tableEnv.toDataSet( table, Row.class );


TableSink sink = new CsvTableSink("/tmp/results", ",");
// write the result Table to the TableSink
// start the job

/tmp/results is a folder, because flink does parallel operations. Hence, if you have 4 processors, you will likely have 4 files in the results folder.

Also, note that we explicitely call env.execute(): this is necessary to start a flink job, but in the previous examples print() did it for us.