yuqi1129 commented on code in PR #11113:
URL: https://github.com/apache/gravitino/pull/11113#discussion_r3657124046
##########
lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceNamespaceWrapper.java:
##########
@@ -135,4 +169,400 @@ public Catalog loadAndValidateLakehouseCatalog(String
catalogName) {
}
return catalog;
}
+
+ String[] listSchemas(Catalog catalog) throws NoSuchCatalogException {
+ SchemaDispatcher schemaDispatcher = currentSchemaDispatcher();
+ if (schemaDispatcher != null) {
+ return
Arrays.stream(schemaDispatcher.listSchemas(Namespace.of(metalakeName,
catalog.name())))
+ .map(NameIdentifier::name)
+ .toArray(String[]::new);
+ }
+
+ if (catalog instanceof BaseCatalog) {
+ CatalogOperations ops = ((BaseCatalog<?>) catalog).ops();
+ if (ops instanceof SupportsSchemas) {
+ return Arrays.stream(((SupportsSchemas)
ops).listSchemas(Namespace.of()))
+ .map(NameIdentifier::name)
+ .toArray(String[]::new);
+ }
+ }
+
+ return catalog.asSchemas().listSchemas();
+ }
+
+ boolean schemaExists(Catalog catalog, String schemaName) {
+ SchemaDispatcher schemaDispatcher = currentSchemaDispatcher();
+ if (schemaDispatcher != null) {
+ return schemaDispatcher.schemaExists(schemaIdent(catalog.name(),
schemaName));
+ }
+
+ if (catalog instanceof BaseCatalog) {
+ CatalogOperations ops = ((BaseCatalog<?>) catalog).ops();
+ if (ops instanceof SupportsSchemas) {
+ return ((SupportsSchemas)
ops).schemaExists(NameIdentifier.of(schemaName));
+ }
+ }
+
+ return catalog.asSchemas().schemaExists(schemaName);
+ }
+
+ Schema loadSchema(Catalog catalog, String schemaName) {
+ SchemaDispatcher schemaDispatcher = currentSchemaDispatcher();
+ if (schemaDispatcher != null) {
+ return schemaDispatcher.loadSchema(schemaIdent(catalog.name(),
schemaName));
+ }
+
+ if (catalog instanceof BaseCatalog) {
+ CatalogOperations ops = ((BaseCatalog<?>) catalog).ops();
+ if (ops instanceof SupportsSchemas) {
+ return ((SupportsSchemas)
ops).loadSchema(NameIdentifier.of(schemaName));
+ }
+ }
Review Comment:
For embedded mode, the code will go to L212, and for non-embedded mode, the
code should run into L222, so why do we need to check the logic?
--
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]