You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Soheil Pourbafrani <so...@gmail.com> on 2019/01/25 19:16:31 UTC

Print table contents

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

Re: Print table contents

Posted by Soheil Pourbafrani <so...@gmail.com>.
Thanks a lot.

On Sat, Jan 26, 2019 at 10:22 AM Hequn Cheng <ch...@gmail.com> 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
>
> [1]
> https://ci.apache.org/projects/flink/flink-docs-master/dev/table/common.html#convert-a-table-into-a-dataset
>
>
> On Sat, Jan 26, 2019 at 3:24 AM Soheil Pourbafrani <so...@gmail.com>
> 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
>>
>

Re: Print table contents

Posted by Hequn Cheng <ch...@gmail.com>.
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

[1]
https://ci.apache.org/projects/flink/flink-docs-master/dev/table/common.html#convert-a-table-into-a-dataset


On Sat, Jan 26, 2019 at 3:24 AM Soheil Pourbafrani <so...@gmail.com>
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
>