bowenli86 commented on a change in pull request #8940: [FLINK-13047][table] Fix 
the Optional.orElse() usage issue in Databas…
URL: https://github.com/apache/flink/pull/8940#discussion_r299256624
 
 

 ##########
 File path: 
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/catalog/DatabaseCalciteSchema.java
 ##########
 @@ -105,8 +105,10 @@ private Table 
convertConnectorTable(ConnectorCatalogTable<?, ?> table) {
 
        private Table convertCatalogTable(ObjectPath tablePath, CatalogTable 
table) {
                Optional<TableFactory> tableFactory = catalog.getTableFactory();
-               TableSource<Row> tableSource = tableFactory.map(tf -> 
((TableSourceFactory) tf).createTableSource(tablePath, table))
-                       
.orElse(TableFactoryUtil.findAndCreateTableSource(table));
+               TableSource<Row> tableSource = tableFactory.map(tf -> 
((TableSourceFactory) tf).createTableSource(tablePath, table)).get();
 
 Review comment:
   by comparing the logic here and `HiveTableFactory.createTableSource()`, I 
found there are duplicated calls on 
`TableFactoryUtil.findAndCreateTableSource(table)`. That made me wonder if any 
table factory implementation shouldn't call the generic table discovery service 
(a.k.a `TableFactoryUtil.findAndCreateTableSource`), and should just create 
tables that is specific to that table factory itself. 
   
   Thus, the `HiveTableFactory.createTableSource` should just be as the 
following:
   
   ```
   @Override
        public TableSource<Row> createTableSource(ObjectPath tablePath, 
CatalogTable table) {
                ...
   
                if (!isGeneric) {
                        return createInputFormatTableSource(tablePath, table);
                } else {
                        return null;
                }
        }
   ```

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