pvary commented on code in PR #13847:
URL: https://github.com/apache/iceberg/pull/13847#discussion_r2285389540


##########
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveOperationsBase.java:
##########
@@ -119,6 +121,30 @@ static void validateTableIsIcebergView(Table table, String 
fullName) {
         table.getTableType());
   }
 
+  static void validateIcebergTableNotLoadedAsIcebergView(Table table, String 
fullName) {
+    String tableType = 
table.getParameters().get(BaseMetastoreTableOperations.TABLE_TYPE_PROP);
+    boolean isIcebergTable =
+        
BaseMetastoreTableOperations.ICEBERG_TABLE_TYPE_VALUE.equalsIgnoreCase(tableType);
+    boolean isIcebergView =
+        TableType.VIRTUAL_VIEW.name().equalsIgnoreCase(table.getTableType())
+            && ICEBERG_VIEW_TYPE_VALUE.equalsIgnoreCase(tableType);
+    if (!isIcebergView && isIcebergTable) {
+      throw new NoSuchViewException("View does not exist: %s", fullName);
+    }
+  }
+
+  static void validateIcebergViewNotLoadedAsIcebergTable(Table table, String 
fullName) {
+    String tableType = 
table.getParameters().get(BaseMetastoreTableOperations.TABLE_TYPE_PROP);
+    boolean isIcebergTable =
+        
BaseMetastoreTableOperations.ICEBERG_TABLE_TYPE_VALUE.equalsIgnoreCase(tableType);
+    boolean isIcebergView =
+        TableType.VIRTUAL_VIEW.name().equalsIgnoreCase(table.getTableType())
+            && ICEBERG_VIEW_TYPE_VALUE.equalsIgnoreCase(tableType);

Review Comment:
   These booleans are calculated several times here, and the 
`validateTableIsIcebergView`, `validateTableIsIceberg`.
   Might worth to extract to a method



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to