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


##########
core/src/main/java/org/apache/gravitino/storage/relational/service/SchemaMetaService.java:
##########
@@ -162,18 +168,54 @@ public List<SchemaEntity> 
listSchemasByNamespace(Namespace namespace) {
   public void insertSchema(SchemaEntity schemaEntity, boolean overwrite) 
throws IOException {
     try {
       NameIdentifierUtil.checkSchema(schemaEntity.nameIdentifier());
-
-      SchemaPO.Builder builder = SchemaPO.builder();
-      fillSchemaPOBuilderParentEntityId(builder, schemaEntity.namespace());
+      // Callers above this service (e.g. JDBCBackend + naming bridge) pass 
storage-form schema
+      // names: nested paths use the internal physical separator, not the 
external logical one.
+      String physicalSep = HierarchicalSchemaUtil.physicalSeparator();
+      String schemaName = schemaEntity.name();
+      List<SchemaEntity> rowsToInsert = new ArrayList<>();
+      if (schemaName == null || !schemaName.contains(physicalSep)) {
+        rowsToInsert.add(schemaEntity);
+      } else {
+        String[] parts = schemaName.split(Pattern.quote(physicalSep), -1);
+        for (int nSeg = 1; nSeg < parts.length; nSeg++) {
+          String ancestorPhysical = String.join(physicalSep, 
Arrays.copyOf(parts, nSeg));
+          SchemaEntity ancestor =
+              SchemaEntity.builder()
+                  .withId(nextIdForNestedAncestor())
+                  .withName(ancestorPhysical)
+                  .withNamespace(schemaEntity.namespace())
+                  .withComment(null)

Review Comment:
   It seems that this will overwrite any existing parents with non empty 
properties and comment, is it expected?



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