roryqi commented on code in PR #11036:
URL: https://github.com/apache/gravitino/pull/11036#discussion_r3228233149
##########
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)
+ .withProperties(Collections.emptyMap())
+ .withAuditInfo(schemaEntity.auditInfo())
+ .build();
+ rowsToInsert.add(ancestor);
+ }
+ rowsToInsert.add(schemaEntity);
+ }
SessionUtils.doWithCommit(
Review Comment:
I corrected this place. AI changed the logic. I don't notice this point. I
merge all the insert operations into one operation.
--
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]