2424import com .dtstack .flink .sql .parser .InsertSqlParser ;
2525import com .dtstack .flink .sql .parser .SqlParser ;
2626import com .dtstack .flink .sql .parser .SqlTree ;
27+ import com .dtstack .flink .sql .util .TypeInfoDataTypeConverter ;
2728import org .apache .flink .api .common .typeinfo .TypeInformation ;
2829import org .apache .flink .api .java .typeutils .RowTypeInfo ;
2930import org .apache .flink .streaming .api .datastream .DataStream ;
6263import org .apache .calcite .sql .SqlNode ;
6364import org .apache .commons .io .Charsets ;
6465import org .apache .commons .lang3 .StringUtils ;
66+ import org .apache .flink .table .types .DataType ;
67+ import org .apache .flink .table .types .utils .TypeConversions ;
6568import org .slf4j .Logger ;
6669import org .slf4j .LoggerFactory ;
6770
7881import java .util .Set ;
7982import java .util .TimeZone ;
8083import java .util .ArrayList ;
84+ import java .util .stream .Stream ;
8185
8286/**
8387 * 任务执行时的流程方法
@@ -287,7 +291,7 @@ public static Set<URL> registerTable(SqlTree sqlTree, StreamExecutionEnvironment
287291 String adaptSql = sourceTableInfo .getAdaptSelectSql ();
288292 Table adaptTable = adaptSql == null ? table : tableEnv .sqlQuery (adaptSql );
289293
290- RowTypeInfo typeInfo = new RowTypeInfo (adaptTable .getSchema ().getFieldTypes ( ), adaptTable .getSchema ().getFieldNames ());
294+ RowTypeInfo typeInfo = new RowTypeInfo (fromDataTypeToLegacyInfo ( adaptTable .getSchema ().getFieldDataTypes () ), adaptTable .getSchema ().getFieldNames ());
291295 DataStream adaptStream = tableEnv .toAppendStream (adaptTable , typeInfo );
292296
293297 String fields = String .join ("," , typeInfo .getFieldNames ());
@@ -380,4 +384,10 @@ private static void timeZoneCheck(String timeZone) {
380384 throw new IllegalArgumentException (String .format (" timezone of %s is Incorrect!" , timeZone ));
381385 }
382386 }
387+
388+ private static TypeInformation <?>[] fromDataTypeToLegacyInfo (DataType [] dataType ) {
389+ return Stream .of (dataType )
390+ .map (TypeInfoDataTypeConverter ::toLegacyTypeInfo )
391+ .toArray (TypeInformation []::new );
392+ }
383393}
0 commit comments