***UNCHECKED*** Table To String

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

***UNCHECKED*** Table To String

Steve Beischlien
I have created a project to use SQL but instead of printing the output as below I need the output in a STRING so I can write it to a dynamoDB table.

How do I convert this "result" to a STRING or is there a suggestion of some other way I should sink to dynamoDB?  Any example code would REALLY help. THANKS!!

Table result = tableEnv.sql("SELECT 'Alert ',t_sKey, t_deviceID, t_sValue FROM SENSORS WHERE t_sKey='TEMPERATURE' AND t_sValue > " + TEMPERATURE_THRESHOLD);
tableEnv.toAppendStream(result, Row.class).print();
Any assistance would be very appreciated.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: ***UNCHECKED*** Table To String

Timo Walther
Hi Steve,

if you are ok with using the DataStream API you can simply use a map() function [1] and call row.toString(). However, usually people want custom logic to construct a string. This logic could either be in SQL using the concat operator `||` or in the DataStream API.

Regards,
Timo



Am 13.11.18 um 07:46 schrieb Steve Beischlien:
I have created a project to use SQL but instead of printing the output as below I need the output in a STRING so I can write it to a dynamoDB table.

How do I convert this "result" to a STRING or is there a suggestion of some other way I should sink to dynamoDB?  Any example code would REALLY help. THANKS!!

Table result = tableEnv.sql("SELECT 'Alert ',t_sKey, t_deviceID, t_sValue FROM SENSORS WHERE t_sKey='TEMPERATURE' AND t_sValue > " + TEMPERATURE_THRESHOLD);
tableEnv.toAppendStream(result, Row.class).print();
Any assistance would be very appreciated.

Thanks


Reply | Threaded
Open this post in threaded view
|

Re: ***UNCHECKED*** Table To String

Timo Walther
I would recommend the training exercises by data Artisans [1]. They have challenging exercises and also nice solutions in Java and Scala.

Flink's end-to-end test also contain a lot of good example code [2].

I hope this helps.

Regards,
Timo



Am 13.11.18 um 16:28 schrieb Steve Bistline:
Hi Timo,

Thank you... I am not very good with the MapFunction and trying to find an example. Will hack at it a bit. 

Appreciate your help.

Steve

On Tue, Nov 13, 2018 at 12:42 AM Timo Walther <[hidden email]> wrote:
Hi Steve,

if you are ok with using the DataStream API you can simply use a map() function [1] and call row.toString(). However, usually people want custom logic to construct a string. This logic could either be in SQL using the concat operator `||` or in the DataStream API.

Regards,
Timo



Am 13.11.18 um 07:46 schrieb Steve Beischlien:
I have created a project to use SQL but instead of printing the output as below I need the output in a STRING so I can write it to a dynamoDB table.

How do I convert this "result" to a STRING or is there a suggestion of some other way I should sink to dynamoDB?  Any example code would REALLY help. THANKS!!

Table result = tableEnv.sql("SELECT 'Alert ',t_sKey, t_deviceID, t_sValue FROM SENSORS WHERE t_sKey='TEMPERATURE' AND t_sValue > " + TEMPERATURE_THRESHOLD);
tableEnv.toAppendStream(result, Row.class).print();
Any assistance would be very appreciated.

Thanks