Aireed commented on code in PR #2814:
URL: https://github.com/apache/amoro/pull/2814#discussion_r1593470115


##########
amoro-mixed-format/amoro-mixed-format-flink/amoro-mixed-format-flink-common/src/main/java/org/apache/amoro/flink/catalog/FlinkUnifiedCatalog.java:
##########
@@ -221,8 +226,25 @@ public void createTable(ObjectPath tablePath, 
CatalogBaseTable table, boolean ig
     TableIdentifier tableIdentifier =
         TableIdentifier.of(
             unifiedCatalog.name(), tablePath.getDatabaseName(), 
tablePath.getObjectName());
+    if (!configuration.contains(TABLE_FORMAT)) {
+      // if user doesn't specify the table format, we try to load the table 
and get the table
+      // format.
+      try {
+        AmoroTable amoroTable =
+            unifiedCatalog.loadTable(tableIdentifier.getDatabase(), 
tableIdentifier.getTableName());
+        format = amoroTable.format();
+      } catch (Throwable t) {
+        LOG.warn(
+            "We can't load table {}.{} through unifiedCatalog, use default 
format {}",
+            tablePath.getDatabaseName(),
+            tablePath.getObjectName(),
+            format.name());
+      }
+    }
+    final TableFormat catalogFormat = format;
     AbstractCatalog catalog =
-        getOriginalCatalog(format).orElseGet(() -> 
createOriginalCatalog(tableIdentifier, format));
+        getOriginalCatalog(format)
+            .orElseGet(() -> createOriginalCatalog(tableIdentifier, 
catalogFormat));

Review Comment:
   > Did we should force user to add 'table.format' option in create table 
statement?
   Good idea. If the table cannot be loaded via unifiedCatalog and no format is 
specified, we should report an error to prompt the user to specify the format. 
WDYT?
   
    
   
   



##########
amoro-mixed-format/amoro-mixed-format-flink/amoro-mixed-format-flink-common/src/main/java/org/apache/amoro/flink/catalog/FlinkUnifiedCatalog.java:
##########
@@ -221,8 +226,25 @@ public void createTable(ObjectPath tablePath, 
CatalogBaseTable table, boolean ig
     TableIdentifier tableIdentifier =
         TableIdentifier.of(
             unifiedCatalog.name(), tablePath.getDatabaseName(), 
tablePath.getObjectName());
+    if (!configuration.contains(TABLE_FORMAT)) {
+      // if user doesn't specify the table format, we try to load the table 
and get the table
+      // format.
+      try {
+        AmoroTable amoroTable =
+            unifiedCatalog.loadTable(tableIdentifier.getDatabase(), 
tableIdentifier.getTableName());
+        format = amoroTable.format();
+      } catch (Throwable t) {
+        LOG.warn(
+            "We can't load table {}.{} through unifiedCatalog, use default 
format {}",
+            tablePath.getDatabaseName(),
+            tablePath.getObjectName(),
+            format.name());
+      }
+    }
+    final TableFormat catalogFormat = format;
     AbstractCatalog catalog =
-        getOriginalCatalog(format).orElseGet(() -> 
createOriginalCatalog(tableIdentifier, format));
+        getOriginalCatalog(format)
+            .orElseGet(() -> createOriginalCatalog(tableIdentifier, 
catalogFormat));

Review Comment:
   > Did we should force user to add 'table.format' option in create table 
statement?
   
   Good idea. If the table cannot be loaded via unifiedCatalog and no format is 
specified, we should report an error to prompt the user to specify the format. 
WDYT?
   
    
   
   



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to