You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "mchades (via GitHub)" <gi...@apache.org> on 2026/08/25 15:51:47 UTC
[PR] [#12601] feat(store): Add Semantic Model list, alter, and drop support [gravitino]
mchades opened a new pull request, #12603:
URL: https://github.com/apache/gravitino/pull/12603
### What changes were proposed in this pull request?
Add relational persistence for listing, altering, and dropping Semantic Models, including optimistic locking, cascade handling, hard deletion, version retention, and cleanup integration.
The feature delta is 18 files, with 1,705 insertions and 65 deletions.
### Why are the changes needed?
Semantic Models need complete relational lifecycle support beyond create and load operations.
Fix: #12601
### Does this PR introduce _any_ user-facing change?
No new public API, REST, OpenAPI, or client surface is introduced.
### How was this patch tested?
- Spotless, Javadoc, compilation, test compilation, and `git diff --check` passed.
- `TestSemanticModelJDBCBackend` passed 18/18 across H2, MySQL, and PostgreSQL.
- `TestSemanticModelMetaService` passed 21/21.
- `TestBaseEntityCache` passed 6/6.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12601] feat(store): Add Semantic Model list, alter, and drop support [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12603:
URL: https://github.com/apache/gravitino/pull/12603#discussion_r4118833086
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/SemanticModelPOStorageOps.java:
##########
@@ -80,6 +88,38 @@ public SemanticModelPO getPOByFullName(
return po;
}
+ @Override
+ public List<SemanticModelPO> listPOs(SemanticModelMetaMapper mapper, Long parentId) {
+ return mapper.listSemanticModelPOsBySchemaId(parentId);
+ }
+
+ @Override
+ public List<SemanticModelPO> listPOs(
+ SemanticModelMetaMapper mapper, List<Long> semanticModelIds) {
+ return mapper.listSemanticModelPOsBySemanticModelIds(semanticModelIds);
+ }
+
+ @Override
+ public List<SemanticModelPO> listPOsByNSFullName(
+ SemanticModelMetaMapper mapper, Namespace namespace) {
+ List<SemanticModelPO> pos =
+ mapper.listSemanticModelPOsByFullQualifiedName(
+ namespace.level(0), namespace.level(1), namespace.level(2));
+ if (pos.isEmpty()) {
+ throw new NoSuchEntityException(
+ NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
+ Entity.EntityType.CATALOG.name().toLowerCase(Locale.ROOT),
+ namespace.level(1));
+ }
+ if (pos.get(0).getSchemaId() == null) {
+ throw new NoSuchEntityException(
+ NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
+ Entity.EntityType.SCHEMA.name().toLowerCase(Locale.ROOT),
+ namespace.level(2));
Review Comment:
Added explicit list-route coverage for both cache modes in 468028ab53. The full-name route now verifies the missing-catalog and missing-schema messages and that an existing empty schema returns an empty list. TestSemanticModelJDBCBackend passes on H2, MySQL, and PostgreSQL (33/33).
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12601] feat(store): Add Semantic Model list, alter, and drop support [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12603:
URL: https://github.com/apache/gravitino/pull/12603#discussion_r4118832241
##########
core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/DefaultMapperPackageProvider.java:
##########
@@ -83,9 +83,9 @@ public List<Class<?>> getMapperClasses() {
PolicyVersionMapper.class,
RoleMetaMapper.class,
SchemaMetaMapper.class,
- SecurableObjectMapper.class,
SemanticModelMetaMapper.class,
SemanticModelVersionInfoMapper.class,
+ SecurableObjectMapper.class,
Review Comment:
This was accidental. I restored SecurableObjectMapper to its original alphabetical position in 468028ab53.
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/SemanticModelPOStorageOps.java:
##########
@@ -80,6 +88,38 @@ public SemanticModelPO getPOByFullName(
return po;
}
+ @Override
+ public List<SemanticModelPO> listPOs(SemanticModelMetaMapper mapper, Long parentId) {
+ return mapper.listSemanticModelPOsBySchemaId(parentId);
+ }
+
+ @Override
+ public List<SemanticModelPO> listPOs(
+ SemanticModelMetaMapper mapper, List<Long> semanticModelIds) {
+ return mapper.listSemanticModelPOsBySemanticModelIds(semanticModelIds);
Review Comment:
Removed the unused ID-list override and the corresponding mapper and SQL provider methods in 468028ab53. The path can be added together with its MetadataObjectService consumer when the Semantic Model securable-object integration lands.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12601] feat(store): Add Semantic Model list, alter, and drop support [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #12603:
URL: https://github.com/apache/gravitino/pull/12603#discussion_r4118354409
##########
core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/DefaultMapperPackageProvider.java:
##########
@@ -83,9 +83,9 @@ public List<Class<?>> getMapperClasses() {
PolicyVersionMapper.class,
RoleMetaMapper.class,
SchemaMetaMapper.class,
- SecurableObjectMapper.class,
SemanticModelMetaMapper.class,
SemanticModelVersionInfoMapper.class,
+ SecurableObjectMapper.class,
Review Comment:
[Question] This moves `SecurableObjectMapper` from before the two new Semantic Model mappers to after them, which is the only change in this file and is unrelated to list/alter/drop. The surrounding list is alphabetical and `Sec` sorts before `Sem`, so the pre-PR order was the correct one; the new order is the odd entry.
Was this deliberate -- e.g. a MyBatis registration-order requirement you hit while adding `semanticModelPOResultMap` and the nested `mapToSemanticModelVersionInfoPO` map? If so it deserves a comment, because a future alphabetical tidy-up would silently undo it. If it was accidental, please revert the move to keep the diff to the feature.
Verified by: this is the entire diff for the file (`git diff -U0 origin/main...HEAD` shows one removal at old line 86 and one addition at new line 88); I grepped `SecurableObjectMapper` and found no `@ResultMap`/`@One` reference to any Semantic Model result map, and no test asserts the contents or order of `getMapperClasses()`.
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/SemanticModelPOStorageOps.java:
##########
@@ -80,6 +88,38 @@ public SemanticModelPO getPOByFullName(
return po;
}
+ @Override
+ public List<SemanticModelPO> listPOs(SemanticModelMetaMapper mapper, Long parentId) {
+ return mapper.listSemanticModelPOsBySchemaId(parentId);
+ }
+
+ @Override
+ public List<SemanticModelPO> listPOs(
+ SemanticModelMetaMapper mapper, List<Long> semanticModelIds) {
+ return mapper.listSemanticModelPOsBySemanticModelIds(semanticModelIds);
+ }
+
+ @Override
+ public List<SemanticModelPO> listPOsByNSFullName(
+ SemanticModelMetaMapper mapper, Namespace namespace) {
+ List<SemanticModelPO> pos =
+ mapper.listSemanticModelPOsByFullQualifiedName(
+ namespace.level(0), namespace.level(1), namespace.level(2));
+ if (pos.isEmpty()) {
+ throw new NoSuchEntityException(
+ NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
+ Entity.EntityType.CATALOG.name().toLowerCase(Locale.ROOT),
+ namespace.level(1));
+ }
+ if (pos.get(0).getSchemaId() == null) {
+ throw new NoSuchEntityException(
+ NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
+ Entity.EntityType.SCHEMA.name().toLowerCase(Locale.ROOT),
+ namespace.level(2));
Review Comment:
[Nit] Neither `NoSuchEntityException` branch here is covered, and the full-qualified-name route itself is never taken in a test. `TestSemanticModelJDBCBackend.testSemanticModelReadRoutesAndEntityIdResolver:326-332` deliberately drives the single-entity read down both routes via `readSemanticModelPO(ident, cacheEnabled)` and asserts the missing-metalake/catalog/schema cases, but the list path has no counterpart: `listSemanticModelsByNamespace` is only called at `TestSemanticModelMetaService:115` and `:263` and `backend.list(...)` at `TestSemanticModelJDBCBackend:409`, all of which take whichever route `GravitinoEnv.cacheEnabled()` yields.
A sibling of the existing helper -- list under `missing_catalog` and under `missing_schema` with `cacheEnabled=false` -- would pin both messages and cover the empty-schema filter on line 120. This is the lowest-covered changed file in the coverage report (63.89%), which matches.
Verified by: grep for `listSemanticModelsByNamespace`, `backend.list`, and `listPOsByNSFullName` across both new test files; read `readSemanticModelPO` at `TestSemanticModelJDBCBackend.java:616-626`.
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/SemanticModelPOStorageOps.java:
##########
@@ -80,6 +88,38 @@ public SemanticModelPO getPOByFullName(
return po;
}
+ @Override
+ public List<SemanticModelPO> listPOs(SemanticModelMetaMapper mapper, Long parentId) {
+ return mapper.listSemanticModelPOsBySchemaId(parentId);
+ }
+
+ @Override
+ public List<SemanticModelPO> listPOs(
+ SemanticModelMetaMapper mapper, List<Long> semanticModelIds) {
+ return mapper.listSemanticModelPOsBySemanticModelIds(semanticModelIds);
Review Comment:
[Nit] This `listPOs(mapper, List<Long>)` override and the `listSemanticModelPOsBySemanticModelIds` mapper method plus its base and PostgreSQL SQL have no caller. The only consumer of the id-list variant is `MetadataObjectService` (`:362` functions, `:416` tables, `:565` views, `:636` schemas), which has no `SEMANTIC_MODEL` branch, and `JDBCBackend.batchGet` resolves semantic models one identifier at a time instead (`JDBCBackend.java:368-380`).
Either point `batchGet` at a `batchGetSemanticModelByIdentifier` built on this batch SQL -- the rows are already fetched by natural key, so only a name-to-id step is missing -- or drop the override until the securable-object work in the `TODO` at `SemanticModelMetaService.java:390-391` needs it. `VIEW` has the same per-identifier loop under the `TODO` at `JDBCBackend.java:334`, so following it is defensible; I am flagging it only because this PR ships the batch query that would fix it.
Verified by: repo-wide grep for `listSemanticModelPOsBySemanticModelIds` and for `ops.listPOs(` over `core/src/main/java` -- the only hits for the id-list form are the four `MetadataObjectService` call sites and `HierarchicalConversionPOStorageOps:99`.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12601] feat(store): Add Semantic Model list, alter, and drop support [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12603:
URL: https://github.com/apache/gravitino/pull/12603#issuecomment-5414252913
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|68.22% **`+0.41%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|85.71%|:green_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|19.74%|:red_circle:|
|api|52.94%|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|authorization-ranger|4.38%|:red_circle:|
|aws|53.54%|:green_circle:|
|azure|32.1%|:red_circle:|
|catalog-common|9.9%|:red_circle:|
|catalog-fileset|80.02%|:green_circle:|
|catalog-glue|69.24%|:green_circle:|
|catalog-hive|82.96%|:green_circle:|
|catalog-jdbc-common|45.69%|:green_circle:|
|catalog-jdbc-doris|82.44%|:green_circle:|
|catalog-jdbc-mysql|79.33%|:green_circle:|
|catalog-jdbc-postgresql|83.39%|:green_circle:|
|catalog-jdbc-starrocks|79.16%|:green_circle:|
|catalog-kafka|76.99%|:green_circle:|
|catalog-lakehouse-generic|59.35%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|85.93%|:green_circle:|
|catalog-lakehouse-paimon|84.26%|:green_circle:|
|catalog-model|77.99%|:green_circle:|
|cli|44.48%|:green_circle:|
|client-java|78.07%|:green_circle:|
|common|52.29%|:green_circle:|
|core|83.47% **`+0.18%`**|:green_circle:|
|filesystem-hadoop3|76.45%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|50.29%|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|32.2%|:red_circle:|
|hadoop-auth|68.0%|:green_circle:|
|hadoop-common|17.84%|:red_circle:|
|hive-metastore-common|53.4%|:green_circle:|
|iceberg-aliyun-bundle|0.0%|:red_circle:|
|iceberg-common|64.75%|:green_circle:|
|iceberg-rest-server|75.31%|:green_circle:|
|idp-basic|85.98%|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|62.92%|:green_circle:|
|lance-common|32.81%|:red_circle:|
|lance-rest-server|64.78%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|83.24%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|87.51%|:green_circle:|
|server-common|79.59%|:green_circle:|
|spark|28.57%|:red_circle:|
|spark-common|48.92%|:green_circle:|
|tencent|69.84%|:green_circle:|
|trino-connector|47.41%|:green_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|core|[Entity.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/Entity.java)|100.0%|:green_circle:|
||[DefaultMapperPackageProvider.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/DefaultMapperPackageProvider.java)|100.0%|:green_circle:|
||[SemanticModelMetaPostgreSQLProvider.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/SemanticModelMetaPostgreSQLProvider.java)|100.0%|:green_circle:|
||[SemanticModelVersionInfoPostgreSQLProvider.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/SemanticModelVersionInfoPostgreSQLProvider.java)|100.0%|:green_circle:|
||[MetalakeMetaService.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/service/MetalakeMetaService.java)|99.34%|:green_circle:|
||[SemanticModelMetaService.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/service/SemanticModelMetaService.java)|98.82%|:green_circle:|
||[SemanticModelEntity.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/meta/SemanticModelEntity.java)|98.57%|:green_circle:|
||[SchemaMetaService.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/service/SchemaMetaService.java)|97.67%|:green_circle:|
||[CatalogMetaService.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/service/CatalogMetaService.java)|95.31%|:green_circle:|
||[SemanticModelDefinitionSerDe.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/po/SemanticModelDefinitionSerDe.java)|92.77%|:green_circle:|
||[BaseEntityCache.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/cache/BaseEntityCache.java)|92.31%|:green_circle:|
||[SemanticModelPO.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/po/SemanticModelPO.java)|92.0%|:green_circle:|
||[SemanticModelVersionInfoBaseSQLProvider.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/SemanticModelVersionInfoBaseSQLProvider.java)|91.67%|:green_circle:|
||[NamespaceUtil.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/utils/NamespaceUtil.java)|88.41%|:green_circle:|
||[SemanticModelVersionInfoSQLProviderFactory.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/SemanticModelVersionInfoSQLProviderFactory.java)|86.36%|:green_circle:|
||[JDBCBackend.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/JDBCBackend.java)|85.0%|:green_circle:|
||[SemanticModelVersionInfoPO.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/po/SemanticModelVersionInfoPO.java)|80.49%|:green_circle:|
||[RelationalEntityStoreIdResolver.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStoreIdResolver.java)|78.9%|:green_circle:|
||[NameIdentifierUtil.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/utils/NameIdentifierUtil.java)|74.48%|:green_circle:|
||[SemanticModelMetaSQLProviderFactory.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/SemanticModelMetaSQLProviderFactory.java)|74.07%|:green_circle:|
||[SemanticModelMetaBaseSQLProvider.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/SemanticModelMetaBaseSQLProvider.java)|63.16%|:green_circle:|
||[MetadataObjectUtil.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/utils/MetadataObjectUtil.java)|58.33%|:red_circle:|
||[SemanticModelPOStorageOps.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/service/SemanticModelPOStorageOps.java)|24.32%|:red_circle:|
||[SemanticModelMetaMapper.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/SemanticModelMetaMapper.java)|0.0%|:red_circle:|
||[SemanticModelVersionInfoMapper.java](https://github.com/mchades/gravitino/blob/15508f7048659392eef8e1c02ddbbbd60141142a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/SemanticModelVersionInfoMapper.java)|0.0%|:red_circle:|
</details>
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12601] feat(store): Add Semantic Model list, alter, and drop support [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12603:
URL: https://github.com/apache/gravitino/pull/12603#discussion_r4095134593
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/SemanticModelMetaService.java:
##########
@@ -156,11 +186,246 @@ public void insertSemanticModel(SemanticModelEntity semanticModelEntity, boolean
}
}
+ /**
+ * Atomically creates a complete new snapshot and advances the current version pointer.
+ *
+ * @param identifier The current Semantic Model identifier.
+ * @param updater The entity updater.
+ * @param <E> The internal entity type accepted by the updater.
+ * @return The updated Semantic Model entity.
+ * @throws IOException If persistence fails.
+ * @throws OptimisticLockException If the internal transaction loses a concurrent update race.
+ */
+ @Monitored(
+ metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
+ baseMetricName = "updateSemanticModel")
+ public <E extends Entity & HasIdentifier> SemanticModelEntity updateSemanticModel(
+ NameIdentifier identifier, Function<E, E> updater) throws IOException {
+ SemanticModelPO oldSemanticModelPO = getSemanticModelPOByIdentifier(identifier);
+ SemanticModelEntity oldSemanticModelEntity =
+ fromSemanticModelPO(oldSemanticModelPO, identifier.namespace());
+ SemanticModelEntity newEntity = (SemanticModelEntity) updater.apply((E) oldSemanticModelEntity);
+ Preconditions.checkArgument(
+ Objects.equals(oldSemanticModelEntity.id(), newEntity.id()),
+ "The updated Semantic Model entity id: %s should be same with the entity id before: %s",
+ newEntity.id(),
+ oldSemanticModelEntity.id());
+
+ AtomicInteger updateResult = new AtomicInteger(-1);
+ try {
+ SemanticModelPO newSemanticModelPO = updateSemanticModelPO(oldSemanticModelPO, newEntity);
+ String metalakeName = identifier.namespace().level(0);
+ String catalogName = identifier.namespace().level(1);
+ String schemaName = identifier.namespace().level(2);
+ String oldFullName =
+ NameIdentifierUtil.ofSemanticModel(
+ metalakeName, catalogName, schemaName, oldSemanticModelPO.getSemanticModelName())
+ .toString();
+ boolean isRenamed =
+ !Objects.equals(
+ oldSemanticModelPO.getSemanticModelName(), newSemanticModelPO.getSemanticModelName());
+
+ SessionUtils.doMultipleWithCommit(
+ // The Semantic Model and its parent were read before this transaction started. Lock the
+ // observed parent again before either identity or version writes, so a schema cascade
+ // cannot finish its cleanup and then let this update recreate child state below it.
+ () ->
+ SchemaMetaService.getInstance()
+ .lockSchemaForEntityWrite(
+ identifier,
+ oldSemanticModelPO.getSchemaId(),
Review Comment:
If the updater changes the entity namespace, `buildSemanticModelPO` resolves the new schema/catalog IDs, but this transaction locks only the old schema. A concurrent delete of the target schema can therefore complete before this write and leave the identity and inserted snapshot under a deleted schema. Handle namespace changes like the View/Function services by locking the old and target schemas in catalog-before-schema order, or reject namespace changes explicitly.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12601] feat(store): Add Semantic Model list, alter, and drop support [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades merged PR #12603:
URL: https://github.com/apache/gravitino/pull/12603
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12601] feat(store): Add Semantic Model list, alter, and drop support [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12603:
URL: https://github.com/apache/gravitino/pull/12603#discussion_r4105394069
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/SemanticModelMetaService.java:
##########
@@ -156,11 +186,246 @@ public void insertSemanticModel(SemanticModelEntity semanticModelEntity, boolean
}
}
+ /**
+ * Atomically creates a complete new snapshot and advances the current version pointer.
+ *
+ * @param identifier The current Semantic Model identifier.
+ * @param updater The entity updater.
+ * @param <E> The internal entity type accepted by the updater.
+ * @return The updated Semantic Model entity.
+ * @throws IOException If persistence fails.
+ * @throws OptimisticLockException If the internal transaction loses a concurrent update race.
+ */
+ @Monitored(
+ metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
+ baseMetricName = "updateSemanticModel")
+ public <E extends Entity & HasIdentifier> SemanticModelEntity updateSemanticModel(
+ NameIdentifier identifier, Function<E, E> updater) throws IOException {
+ SemanticModelPO oldSemanticModelPO = getSemanticModelPOByIdentifier(identifier);
+ SemanticModelEntity oldSemanticModelEntity =
+ fromSemanticModelPO(oldSemanticModelPO, identifier.namespace());
+ SemanticModelEntity newEntity = (SemanticModelEntity) updater.apply((E) oldSemanticModelEntity);
+ Preconditions.checkArgument(
+ Objects.equals(oldSemanticModelEntity.id(), newEntity.id()),
+ "The updated Semantic Model entity id: %s should be same with the entity id before: %s",
+ newEntity.id(),
+ oldSemanticModelEntity.id());
+
+ AtomicInteger updateResult = new AtomicInteger(-1);
+ try {
+ SemanticModelPO newSemanticModelPO = updateSemanticModelPO(oldSemanticModelPO, newEntity);
+ String metalakeName = identifier.namespace().level(0);
+ String catalogName = identifier.namespace().level(1);
+ String schemaName = identifier.namespace().level(2);
+ String oldFullName =
+ NameIdentifierUtil.ofSemanticModel(
+ metalakeName, catalogName, schemaName, oldSemanticModelPO.getSemanticModelName())
+ .toString();
+ boolean isRenamed =
+ !Objects.equals(
+ oldSemanticModelPO.getSemanticModelName(), newSemanticModelPO.getSemanticModelName());
+
+ SessionUtils.doMultipleWithCommit(
+ // The Semantic Model and its parent were read before this transaction started. Lock the
+ // observed parent again before either identity or version writes, so a schema cascade
+ // cannot finish its cleanup and then let this update recreate child state below it.
+ () ->
+ SchemaMetaService.getInstance()
+ .lockSchemaForEntityWrite(
+ identifier,
+ oldSemanticModelPO.getSchemaId(),
Review Comment:
`SemanticModelChange` has no namespace move operation. I added a namespace check before `buildSemanticModelPO` in 06abe244a2, with a regression test verifying that an attempted move leaves the identity and version unchanged.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org