Re: Using RowTypeInfo with Table API

Posted by Timo Walther on
URL: http://deprecated-apache-flink-user-mailing-list-archive.369.s1.nabble.com/Using-RowTypeInfo-with-Table-API-tp18588p18589.html

Hi Jens,

usually the Flink extracts the type information from the generic
signature of a function. E.g. it knows the fields of a Tuple2<Integer,
String>. The row type cannot be analyzed and therefore always needs
explicit information.

You can create it with org.apache.flink.table.api.Types.ROW(...). You
can check the type of your stream using ds.getType(). You can pass
information explicitly in Scala e.g. ds.map()(Types.ROW(...))

Hope that helps.

Regards,
Timo


Am 2/27/18 um 2:34 PM schrieb Jens Grassel:

> Hi,
>
> I tried to create a table from a DataStream[Row] but got a (somehow
> expected) error:
>
> <---snip--->
> An input of GenericTypeInfo<Row> cannot be converted to Table. Please
> specify the type of the input with a RowTypeInfo.
> <---snip--->
>
> Code looks like this:
>
> val ds: DataStream[Row] = ...
> val dT = streamTableEnvironment.fromDataStream(ds, 'f1, 'f2, ...)
>
> However I have not found an example or hints at how to actually use the
> mentioned RowTypeInfo to specify a column mapping for the table api.
>
> Can anyone shed some light on this?
>
> Regards,
>
> Jens
>