yuqi1129 commented on code in PR #9430:
URL: https://github.com/apache/gravitino/pull/9430#discussion_r2645242123


##########
core/src/main/java/org/apache/gravitino/storage/relational/service/SchemaMetaService.java:
##########
@@ -388,6 +395,40 @@ public int deleteSchemaMetasByLegacyTimeline(Long 
legacyTimeline, int limit) {
         });
   }
 
+  private SchemaPO getSchemaPOByIdentifier(NameIdentifier identifier) {
+    NameIdentifierUtil.checkSchema(identifier);
+    if (GravitinoEnv.getInstance().config().get(Configs.CACHE_ENABLED)) {
+      Long catalogId =
+          EntityIdService.getEntityId(
+              NameIdentifier.of(identifier.namespace().levels()), 
Entity.EntityType.CATALOG);
+      return getSchemaPOByCatalogIdAndName(catalogId, identifier.name());
+    }
+
+    String[] namespaceLevels = identifier.namespace().levels();
+    SchemaPO schemaPO =
+        SessionUtils.getWithoutCommit(
+            SchemaMetaMapper.class,
+            mapper ->
+                mapper.selectSchemaByFullQualifiedName(
+                    namespaceLevels[0], namespaceLevels[1], 
identifier.name()));
+
+    if (schemaPO == null) {
+      throw new NoSuchEntityException(
+          NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
+          Entity.EntityType.CATALOG.name().toLowerCase(),
+          namespaceLevels[1]);

Review Comment:
   We use a left join to fetch schema entities, so as long as the catalog of 
the schema exists, the `schemaPO` will be none. 



##########
scripts/postgresql/upgrade-1.1.0-to-1.2.0-postgresql.sql:
##########
@@ -0,0 +1,25 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"). You may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--  http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+
+CREATE INDEX IF NOT EXISTS catalog_meta_idx_name_da ON catalog_meta 
(catalog_name, deleted_at);
+CREATE INDEX IF NOT EXISTS schema_meta_idx_name_da ON schema_meta 
(schema_name, deleted_at);
+CREATE INDEX IF NOT EXISTS table_meta_idx_name_da ON table_meta (table_name, 
deleted_at);
+CREATE INDEX IF NOT EXISTS fileset_meta_idx_name_da ON fileset_meta 
(fileset_name, deleted_at);
+CREATE INDEX IF NOT EXISTS model_meta_idx_name_da ON model_meta (model_name, 
deleted_at);
+CREATE INDEX IF NOT EXISTS topic_meta_idx_name_da ON topic_meta (topic_name, 
deleted_at);

Review Comment:
   ditto



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