JingsongLi commented on a change in pull request #9909: [FLINK-14381][table] 
Partition field names should be got from CatalogTable instead of source/sink
URL: https://github.com/apache/flink/pull/9909#discussion_r338935633
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/delegation/PlannerBase.scala
 ##########
 @@ -254,28 +252,30 @@ abstract class PlannerBase(
     */
   protected def translateToPlan(execNodes: util.List[ExecNode[_, _]]): 
util.List[Transformation[_]]
 
-  private def getTableSink(objectIdentifier: ObjectIdentifier): 
Option[TableSink[_]] = {
-    JavaScalaConversionUtil.toScala(catalogManager.getTable(objectIdentifier)) 
match {
+  private def getTableSink(identifier: ObjectIdentifier): 
Option[(CatalogTable, TableSink[_])] = {
+    JavaScalaConversionUtil.toScala(catalogManager.getTable(identifier)) match 
{
       case Some(s) if s.isInstanceOf[ConnectorCatalogTable[_, _]] =>
-        JavaScalaConversionUtil
-          .toScala(s.asInstanceOf[ConnectorCatalogTable[_, _]].getTableSink)
+        val table = s.asInstanceOf[ConnectorCatalogTable[_, _]]
+        JavaScalaConversionUtil.toScala(table.getTableSink) match {
+          case Some(sink) => Some(table, sink)
+          case None => None
+        }
 
       case Some(s) if s.isInstanceOf[CatalogTable] =>
-
-        val catalog = 
catalogManager.getCatalog(objectIdentifier.getCatalogName)
-        val catalogTable = s.asInstanceOf[CatalogTable]
+        val catalog = catalogManager.getCatalog(identifier.getCatalogName)
+        val table = s.asInstanceOf[CatalogTable]
         if (catalog.isPresent && catalog.get().getTableFactory.isPresent) {
-          val objectPath = objectIdentifier.toObjectPath
+          val objectPath = identifier.toObjectPath
           val sink = TableFactoryUtil.createTableSinkForCatalogTable(
             catalog.get(),
-            catalogTable,
+            table,
             objectPath)
           if (sink.isPresent) {
-            return Option(sink.get())
+            return Option(table, sink.get())
           }
         }
-        val sinkProperties = catalogTable.toProperties
-        Option(TableFactoryService.find(classOf[TableSinkFactory[_]], 
sinkProperties)
+        val sinkProperties = table.toProperties
+        Option(table, TableFactoryService.find(classOf[TableSinkFactory[_]], 
sinkProperties)
 
 Review comment:
   See `Catalog.getTableFactory`.
   Option 1 use `Catalog.getTableFactory` to get `TableFactory` and create sink.
   Option 2 use `TableFactoryService` to create `TableFactory` and create sink.
   The reason why we need option 1 is that hive table factory can not find by  
`TableFactoryService`, but I think this can be improved in future.

----------------------------------------------------------------
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