Hi folks, is there an easy to convert `DataStream&...
# troubleshooting
t
Hi folks, is there an easy to convert
DataStream<rowdata>
generated from iceberg source to
DataStream<row>
? I am using
RowRowConverter
s
Nothing simpler than
RowRowConverter
in my opinion 🙂
t
but it doesn't return exact schema, I get raw type
Copy code
(
  `f0` RAW('org.apache.flink.types.Row', '...')
)
s
Then you’re doing something wrong
What do you pass to
RowRowConverter.create
?
t
I use
sourceTable.getResolvedSchema().toSourceRowDataType()
where
sourcetable
is
Table sourceTable = tableEnv.fromDataStream(icebergSource);
s
Ah, I remember now. In Scala, you also must provide
RowTypeInfo
as an implicit if you use
RowRowConverter
in something like a
map
or `flatMap`:
Copy code
implicit val rowTypeInfo: RowTypeInfo = DataTypeUtils.createRowTypeInfoFromSchema(tableSchema)
Where
DataTypeUtils.createRowTypeInfoFromSchema
is just my utility to create
RowTypeInfo
from a schema. Not sure what Java alternative to this is.
t
how do you convert datatype to RowTypeInfo? Is there any flink converter class I can use?
I can use same class or re do same logic in java
s
This is my logic in Flink 1.15, but it does use some deprecated classes
Copy code
def createRowTypeInfoFromSchema(schema: Schema): RowTypeInfo = {
    val tableColumns = schema.getColumns.asScala.toList.map(rawColumn => {
      rawColumn.asInstanceOf[UnresolvedPhysicalColumn]
    })

    new RowTypeInfo(
      tableColumns.map(_.getDataType.asInstanceOf[DataType]).map(TypeInfoDataTypeConverter.fromDataTypeToTypeInfo).toArray,
      tableColumns.map(_.getName).toArray
    )
  }
t
thank you! let me try that