xuefuz 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_r299262699
##########
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:
Good point. However, that's not what I meant to do. HiveTableFactory is
responsible to generate table source/sink for both generic and hive tables, so
it needs to take care of both. In DatabaseCalciteSchema.convertCatalogTable(),
it calls TableFactoryUtil.findAndCreateTableSource(table) only if the catalog
doesn't return a table factory object. Thus, there is no duplication per se.
However, I did realize that the logic here is confusion, especially with the
java Optional object. I will refactor the code a bit to make it clearer.
----------------------------------------------------------------
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