pyflink.table.table_result.TableResult.collect#
- TableResult.collect() pyflink.table.table_result.CloseableIterator [source]#
Get the result contents as a closeable row iterator.
Note:
For SELECT operation, the job will not be finished unless all result data has been collected. So we should actively close the job to avoid resource leak through CloseableIterator#close method. Calling CloseableIterator#close method will cancel the job and release related resources.
For DML operation, Flink does not support getting the real affected row count now. So the affected row count is always -1 (unknown) for every sink, and them will be returned until the job is finished. Calling CloseableIterator#close method will cancel the job.
For other operations, no flink job will be submitted (get_job_client() is always empty), and the result is bounded. Do noting when calling CloseableIterator#close method.
Recommended code to call CloseableIterator#close method looks like:
>>> table_result = t_env.execute("select ...") >>> with table_result.collect() as results: >>> for result in results: >>> ...
In order to fetch result to local, you can call either collect() and print(). But, they can not be called both on the same TableResult instance.
- Returns
A CloseableIterator.
New in version 1.12.0.