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
Currently, flink offers only the
In the examples above, replace:
DataSet<Row> result = tableEnv.toDataSet( table, Row.class ); result.print();
TableSink sink = new CsvTableSink("/tmp/results", ","); // write the result Table to the TableSink table.writeToSink(sink); // start the job env.execute();
/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.