wuchong commented on a change in pull request #11236: 
[FLINK-16269][FLINK-16108][table-planner-blink] Fix schema of query and sink do 
not match when generic or POJO type is requested
URL: https://github.com/apache/flink/pull/11236#discussion_r386914676
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/sinks/TableSinkUtils.scala
 ##########
 @@ -189,13 +190,45 @@ object TableSinkUtils {
       queryLogicalType,
       withChangeFlag)
     if (LogicalTypeChecks.isCompositeType(requestedOutputType.getLogicalType)) 
{
-      DataTypeUtils.expandCompositeTypeToSchema(requestedOutputType)
+      fromDataTypeToTypeInfo(requestedOutputType) match {
+        case pj: PojoTypeInfo[_] => expandPojoTypeToSchema(pj, 
queryLogicalType)
+        case _ => 
DataTypeUtils.expandCompositeTypeToSchema(requestedOutputType)
+      }
     } else {
       // atomic type
       TableSchema.builder().field("f0", requestedOutputType).build()
     }
   }
 
+  /**
 
 Review comment:
   Unfortunately, we can't reorder the nested data in `SinkCodeGenerator` for 
now. Because the `ExprCodeGenerator` only accetps the top-level `mapping`. If 
we want to support reorder nested data, `ExprCodeGenerator` requires a major 
refactoring. I will leave that as a future work and it is not a big requirement 
as of right now (it's hard to construct a nested named row for now). 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to