bowenli86 commented on a change in pull request #9971: [FLINK-14490][table] Add 
methods for interacting with temporary objects
URL: https://github.com/apache/flink/pull/9971#discussion_r339230925
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/catalog/DatabaseCalciteSchema.java
 ##########
 @@ -66,109 +68,154 @@
 class DatabaseCalciteSchema extends FlinkSchema {
        private final String databaseName;
        private final String catalogName;
-       private final Catalog catalog;
+       private final CatalogManager catalogManager;
        // Flag that tells if the current planner should work in a batch or 
streaming mode.
        private final boolean isStreamingMode;
 
-       public DatabaseCalciteSchema(String databaseName, String catalogName, 
Catalog catalog, boolean isStreamingMode) {
+       public DatabaseCalciteSchema(String databaseName, String catalogName, 
CatalogManager catalog, boolean isStreamingMode) {
                this.databaseName = databaseName;
                this.catalogName = catalogName;
-               this.catalog = catalog;
+               this.catalogManager = catalog;
                this.isStreamingMode = isStreamingMode;
        }
 
        @Override
        public Table getTable(String tableName) {
-               ObjectPath tablePath = new ObjectPath(databaseName, tableName);
+               ObjectIdentifier identifier = ObjectIdentifier.of(catalogName, 
databaseName, tableName);
+               return catalogManager.getTable(identifier)
+                       .map(result -> {
+                               CatalogBaseTable table = result.getTable();
+                               if (result.isTemporary()) {
+                                       return convertTemporaryTable(new 
ObjectPath(databaseName, tableName), table);
+                               } else {
+                                       return convertPermanentTable(
+                                               identifier.toObjectPath(),
+                                               table,
+                                               
catalogManager.getCatalog(catalogName)
+                                                       
.flatMap(Catalog::getTableFactory)
 
 Review comment:
   minor:  this feels a bit over complicated. How about just call 
`catalogManager.getCatalog(catalogName).getTableFactory()`?

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


With regards,
Apache Git Services

Reply via email to