flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [flink] KurtYoung commented on a change in pull request #9909: [FLINK-14381][table] Partition field names should be got from CatalogTable instead of source/sink
Date Fri, 25 Oct 2019 06:52:00 GMT
KurtYoung 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_r338907827
 
 

 ##########
 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:
   Could you explain what's the difference between `TableFactoryUtil.createTableSinkForCatalogTable`
and `TableFactoryService.find(classOf[TableSinkFactory[_]], sinkProperties)`?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message