mchades commented on code in PR #11288:
URL: https://github.com/apache/gravitino/pull/11288#discussion_r3339049848
##########
spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/catalog/BaseCatalog.java:
##########
@@ -421,6 +435,45 @@ public boolean dropNamespace(String[] namespace, boolean
cascade)
}
}
+ /**
+ * Loads a Gravitino view as a Spark Table when {@link
#loadTable(Identifier)} fails because the
+ * object is a view. Subclasses can override {@link #createSparkView} to
enable view support.
+ *
+ * @param ident the identifier to load
+ * @return Spark Table wrapping the view
+ * @throws NoSuchTableException if no view exists or views are not supported
by this catalog
+ */
+ protected Table loadViewAsTable(Identifier ident) throws
NoSuchTableException {
+ View gravitinoView;
+ try {
+ gravitinoView =
+ gravitinoCatalogClient
+ .asViewCatalog()
+ .loadView(NameIdentifier.of(getDatabase(ident), ident.name()));
+ } catch (NoSuchViewException | UnsupportedOperationException e) {
Review Comment:
`loadView()` can throw `ForbiddenException` (an unchecked exception) when
the caller lacks `LOAD_VIEW` privilege. This will bubble out of `loadTable()`
which only declares `throws NoSuchTableException`, breaking the API contract.
`tableExists()` already handles `ForbiddenException` explicitly — the same
treatment is needed here:
```java
} catch (NoSuchViewException | UnsupportedOperationException |
ForbiddenException e) {
throw new NoSuchTableException(ident);
}
```
--
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]