mchades commented on code in PR #14684:
URL: https://github.com/apache/gravitino/pull/14684#discussion_r4488339414


##########
server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelSourceValidator.java:
##########
@@ -190,6 +210,55 @@ private Set<String> loadColumns(
     throw new IllegalSemanticModelException("Semantic Model source %s does not 
exist", ident);
   }
 
+  private static long registeredTableId(NameIdentifier ident, Table table) {
+    if (table instanceof EntityCombinedTable) {
+      EntityCombinedTable combined = (EntityCombinedTable) table;
+      if (combined.tableFromGravitino() != null) {
+        return combined.tableFromGravitino().id();
+      }
+      // Managed tables carry their stored ID in the loaded catalog 
properties, without a separate
+      // TableEntity. Read it before public-property masking, without 
resolving the name again.
+      if (combined.imported()) {
+        StringIdentifier id =
+            
StringIdentifier.fromProperties(combined.tableFromCatalog().properties());
+        if (id != null) {
+          return id.id();
+        }
+      }
+    }
+    throw new IllegalStateException("Source table has no registered Gravitino 
identity: " + ident);
+  }
+
+  private static long registeredViewId(NameIdentifier ident, View view) {
+    if (view instanceof EntityCombinedView) {
+      EntityCombinedView combined = (EntityCombinedView) view;
+      if (combined.viewEntity() != null) {
+        return combined.viewEntity().id();
+      }
+      // Managed views use the same stored-identity property as managed tables.
+      if (combined.imported()) {
+        StringIdentifier id =
+            
StringIdentifier.fromProperties(combined.viewFromCatalog().properties());
+        if (id != null) {
+          return id.id();
+        }
+      }
+    }
+    throw new IllegalStateException("Source View has no registered Gravitino 
identity: " + ident);
+  }

Review Comment:
   Both types have coverage for entity IDs, the imported-properties fallback, 
and missing identities. A shared accessor helper would add indirection for 
these two short, type-specific methods, so I’m keeping them explicit.



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