Print table contents

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Print table contents

Soheil Pourbafrani
Hi, 

Using Flink Table object how can we print table contents, something like Spark show() method?

for example in the following:

tableEnv.registerDataSet("Orders", raw, "id, country, num, about");
Table results = tableEnv.sqlQuery("SELECT id FROM Orders WHERE id > 10");
How can I print the results variable contents?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Print table contents

Hequn Cheng
Hi Soheil,

There is no print() or show() method in Table. As a workaround, you can convert[1] the Table into a DataSet and perform print() or collect() on the DataSet. 
You have to pay attention to the differences between DataSet.print() and DataSet.collect(). 
For DataSet.print(), prints the elements in a DataSet to the standard output stream {@link System#out} of the JVM that calls the print() method. For programs that are executed in a cluster, this method needs to gather the contents of the DataSet back to the client, to print it there. 
For DataSet.collect(), get the elements of a DataSet as a List. As DataSet can contain a lot of data, this method should be used with caution.

Best,
Hequn



On Sat, Jan 26, 2019 at 3:24 AM Soheil Pourbafrani <[hidden email]> wrote:
Hi, 

Using Flink Table object how can we print table contents, something like Spark show() method?

for example in the following:

tableEnv.registerDataSet("Orders", raw, "id, country, num, about");
Table results = tableEnv.sqlQuery("SELECT id FROM Orders WHERE id > 10");
How can I print the results variable contents?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Print table contents

Soheil Pourbafrani
Thanks a lot. 

On Sat, Jan 26, 2019 at 10:22 AM Hequn Cheng <[hidden email]> wrote:
Hi Soheil,

There is no print() or show() method in Table. As a workaround, you can convert[1] the Table into a DataSet and perform print() or collect() on the DataSet. 
You have to pay attention to the differences between DataSet.print() and DataSet.collect(). 
For DataSet.print(), prints the elements in a DataSet to the standard output stream {@link System#out} of the JVM that calls the print() method. For programs that are executed in a cluster, this method needs to gather the contents of the DataSet back to the client, to print it there. 
For DataSet.collect(), get the elements of a DataSet as a List. As DataSet can contain a lot of data, this method should be used with caution.

Best,
Hequn



On Sat, Jan 26, 2019 at 3:24 AM Soheil Pourbafrani <[hidden email]> wrote:
Hi, 

Using Flink Table object how can we print table contents, something like Spark show() method?

for example in the following:

tableEnv.registerDataSet("Orders", raw, "id, country, num, about");
Table results = tableEnv.sqlQuery("SELECT id FROM Orders WHERE id > 10");
How can I print the results variable contents?

Thanks