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/26 04:23:08 UTC
[PR] [#12608] feat(server): Add Semantic Model list, alter, and drop REST APIs [gravitino]
mchades opened a new pull request, #12626:
URL: https://github.com/apache/gravitino/pull/12626
### What changes were proposed in this pull request?
This PR adds Semantic Model REST APIs for list, alter, and drop, including atomic alter request DTOs, conversion to Semantic Model changes, server routing, exception handling, and focused tests.
This draft is stacked on the updated REST create/load work for #12607 and the unmerged Core list/alter/drop work for #12605. The feature commit itself contains only list/alter/drop changes under common and server.
### Why are the changes needed?
These APIs complete the REST lifecycle for Semantic Models. Alter requests are fully validated and converted before dispatch so an invalid update cannot partially apply the batch.
Fix: #12608
### Does this PR introduce _any_ user-facing change?
Yes. It adds GET list, PUT alter, and DELETE drop REST operations for schema-scoped Semantic Models. Create, load, OpenAPI, and client changes are outside this feature commit.
### How was this patch tested?
The following local checks passed:
- Semantic Model update DTO and REST lifecycle focused tests
- ./gradlew :common:check :server:check -PskipITs
- ./gradlew :common:spotlessApply :server:spotlessApply
- git diff --check
--
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] [#12608] feat(server): Add Semantic Model list, alter, and drop REST APIs [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12626:
URL: https://github.com/apache/gravitino/pull/12626#discussion_r4133773835
##########
server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelOperations.java:
##########
@@ -63,6 +72,44 @@ public SemanticModelOperations(SemanticModelDispatcher dispatcher) {
this.dispatcher = dispatcher;
}
+ /**
+ * Lists Semantic Models in a schema.
+ *
+ * @param metalake The metalake name.
+ * @param catalog The catalog name.
+ * @param schema The schema name.
+ * @return A response containing Semantic Model identifiers.
+ */
+ @GET
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "list-semantic-model." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "list-semantic-model", absolute = true)
+ public Response listSemanticModels(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema) {
+ LOG.info(
+ "Received list Semantic Models request for schema: {}.{}.{}", metalake, catalog, schema);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ Namespace namespace = NamespaceUtil.ofSemanticModel(metalake, catalog, schema);
+ NameIdentifier[] identifiers = dispatcher.listSemanticModels(namespace);
+ identifiers = identifiers == null ? new NameIdentifier[0] : identifiers;
Review Comment:
Removed the unreachable null fallback and the matching `thenReturn(null)` test in 410d754242. The endpoint now relies on the dispatcher contract, consistent with the other list endpoints.
--
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] [#12608] feat(server): Add Semantic Model list, alter, and drop REST APIs [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12626:
URL: https://github.com/apache/gravitino/pull/12626#discussion_r4123049811
##########
server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelOperations.java:
##########
@@ -63,6 +72,44 @@ public SemanticModelOperations(SemanticModelDispatcher dispatcher) {
this.dispatcher = dispatcher;
}
+ /**
+ * Lists Semantic Models in a schema.
+ *
+ * @param metalake The metalake name.
+ * @param catalog The catalog name.
+ * @param schema The schema name.
+ * @return A response containing Semantic Model identifiers.
+ */
+ @GET
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "list-semantic-model." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "list-semantic-model", absolute = true)
+ public Response listSemanticModels(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema) {
+ LOG.info(
+ "Received list Semantic Models request for schema: {}.{}.{}", metalake, catalog, schema);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ Namespace namespace = NamespaceUtil.ofSemanticModel(metalake, catalog, schema);
+ NameIdentifier[] identifiers = dispatcher.listSemanticModels(namespace);
+ identifiers = identifiers == null ? new NameIdentifier[0] : identifiers;
Review Comment:
Authorization filtering is outside the scope of this PR and is tracked in #12594. After incorporating this PR, #13512 will add the schema-level list check and filter the returned identifiers with `FILTER_SEMANTIC_MODEL_AUTHORIZATION_EXPRESSION`.
--
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] [#12608] feat(server): Add Semantic Model list, alter, and drop REST APIs [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12626:
URL: https://github.com/apache/gravitino/pull/12626#issuecomment-5421197915
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|68.54% **`+0.49%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|77.6%|: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.86%|: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|55.73% **`+1.02%`**|:green_circle:|
|core|83.64% **`-0.13%`**|: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.17%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|87.81% **`-1.57%`**|: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||
|:-|:-|:-|:-:|
|common|[CustomExtensionDTO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/CustomExtensionDTO.java)|100.0%|:green_circle:|
||[DatasetDTO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/DatasetDTO.java)|100.0%|:green_circle:|
||[DialectExpressionDTO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/DialectExpressionDTO.java)|100.0%|:green_circle:|
||[DimensionDTO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/DimensionDTO.java)|100.0%|:green_circle:|
||[ExpressionDTO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/ExpressionDTO.java)|100.0%|:green_circle:|
||[FieldDTO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/FieldDTO.java)|100.0%|:green_circle:|
||[MetricDTO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/MetricDTO.java)|100.0%|:green_circle:|
||[RelationshipDTO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/RelationshipDTO.java)|100.0%|:green_circle:|
||[SemanticModelDefinitionDTO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/SemanticModelDefinitionDTO.java)|100.0%|:green_circle:|
||[AIContextDTO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/AIContextDTO.java)|94.74%|:green_circle:|
||[SemanticModelDTO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/SemanticModelDTO.java)|94.29%|:green_circle:|
||[AIContextObjectDTO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/AIContextObjectDTO.java)|89.87%|:green_circle:|
||[SemanticDTOUtils.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/semantic/SemanticDTOUtils.java)|89.74%|:green_circle:|
||[SemanticModelResponse.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/responses/SemanticModelResponse.java)|88.24%|:green_circle:|
||[SemanticModelUpdatesRequest.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/requests/SemanticModelUpdatesRequest.java)|86.67%|:green_circle:|
||[SemanticModelUpdateRequest.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/requests/SemanticModelUpdateRequest.java)|83.61%|:green_circle:|
||[SemanticModelCreateRequest.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/requests/SemanticModelCreateRequest.java)|81.82%|:green_circle:|
||[DTOConverters.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/common/src/main/java/org/apache/gravitino/dto/util/DTOConverters.java)|30.51%|:red_circle:|
|core|[Entity.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/Entity.java)|100.0%|:green_circle:|
||[ManagedSemanticModelOperations.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/catalog/ManagedSemanticModelOperations.java)|100.0%|:green_circle:|
||[DefaultMapperPackageProvider.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/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/34f70c68aba5e62c5058f1f768f35219b0c4a02c/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/34f70c68aba5e62c5058f1f768f35219b0c4a02c/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/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/service/MetalakeMetaService.java)|99.34%|:green_circle:|
||[SemanticModelMetaService.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/service/SemanticModelMetaService.java)|98.82%|:green_circle:|
||[SemanticModelEntity.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/meta/SemanticModelEntity.java)|98.57%|:green_circle:|
||[SchemaMetaService.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/service/SchemaMetaService.java)|97.67%|:green_circle:|
||[SemanticModelOperationDispatcher.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/catalog/SemanticModelOperationDispatcher.java)|97.44%|:green_circle:|
||[Capability.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/connector/capability/Capability.java)|97.44%|:green_circle:|
||[SemanticModelNormalizeDispatcher.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/catalog/SemanticModelNormalizeDispatcher.java)|96.3%|:green_circle:|
||[CatalogMetaService.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/service/CatalogMetaService.java)|95.31%|:green_circle:|
||[SemanticModelDefinitionSerDe.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/po/SemanticModelDefinitionSerDe.java)|92.77%|:green_circle:|
||[BaseEntityCache.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/cache/BaseEntityCache.java)|92.31%|:green_circle:|
||[SemanticModelValidator.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/catalog/SemanticModelValidator.java)|92.21%|:green_circle:|
||[SemanticModelPO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/po/SemanticModelPO.java)|92.0%|:green_circle:|
||[SemanticModelVersionInfoBaseSQLProvider.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/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/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/utils/NamespaceUtil.java)|88.41%|:green_circle:|
||[SemanticModelVersionInfoSQLProviderFactory.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/mapper/SemanticModelVersionInfoSQLProviderFactory.java)|86.36%|:green_circle:|
||[JDBCBackend.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/JDBCBackend.java)|85.0%|:green_circle:|
||[SemanticModelVersionInfoPO.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/po/SemanticModelVersionInfoPO.java)|80.49%|:green_circle:|
||[RelationalEntityStoreIdResolver.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStoreIdResolver.java)|78.9%|:green_circle:|
||[CapabilityHelpers.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/catalog/CapabilityHelpers.java)|78.32%|:green_circle:|
||[NameIdentifierUtil.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/utils/NameIdentifierUtil.java)|74.48%|:green_circle:|
||[SemanticModelMetaSQLProviderFactory.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/mapper/SemanticModelMetaSQLProviderFactory.java)|74.07%|:green_circle:|
||[SemanticModelMetaBaseSQLProvider.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/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/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/utils/MetadataObjectUtil.java)|58.33%|:red_circle:|
||[GravitinoEnv.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/GravitinoEnv.java)|29.82%|:red_circle:|
||[SemanticModelPOStorageOps.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/service/SemanticModelPOStorageOps.java)|24.32%|:red_circle:|
||[SemanticModelDispatcher.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/catalog/SemanticModelDispatcher.java)|0.0%|:red_circle:|
||[SemanticModelMetaMapper.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/mapper/SemanticModelMetaMapper.java)|0.0%|:red_circle:|
||[SemanticModelVersionInfoMapper.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/core/src/main/java/org/apache/gravitino/storage/relational/mapper/SemanticModelVersionInfoMapper.java)|0.0%|:red_circle:|
|server|[SemanticModelOperations.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelOperations.java)|98.51%|:green_circle:|
||[ExceptionHandlers.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/server/src/main/java/org/apache/gravitino/server/web/rest/ExceptionHandlers.java)|84.04%|:green_circle:|
||[GravitinoServer.java](https://github.com/mchades/gravitino/blob/34f70c68aba5e62c5058f1f768f35219b0c4a02c/server/src/main/java/org/apache/gravitino/server/GravitinoServer.java)|63.04%|:green_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] [#12608] feat(server): Add Semantic Model list, alter, and drop REST APIs [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12626:
URL: https://github.com/apache/gravitino/pull/12626#discussion_r4133809521
##########
server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelOperations.java:
##########
@@ -157,4 +204,103 @@ public Response loadSemanticModel(
OperationType.LOAD, semanticModel, schema, e);
}
}
+
+ /**
+ * Alters a Semantic Model atomically.
+ *
+ * @param metalake The metalake name.
+ * @param catalog The catalog name.
+ * @param schema The schema name.
+ * @param semanticModel The current Semantic Model name.
+ * @param request The updates to apply.
+ * @return A response containing the altered Semantic Model.
+ */
+ @PUT
+ @Path("{semanticModel}")
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "alter-semantic-model." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "alter-semantic-model", absolute = true)
+ public Response alterSemanticModel(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema,
+ @PathParam("semanticModel") String semanticModel,
+ SemanticModelUpdatesRequest request) {
+ LOG.info(
+ "Received alter Semantic Model request: {}.{}.{}.{}",
+ metalake,
+ catalog,
+ schema,
+ semanticModel);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ if (request == null) {
+ throw new IllegalArgumentException("Request body must not be null");
+ }
Review Comment:
Added `putJson` and `testAlterSemanticModelRejectsNullBody` in 410d754242. The test sends literal JSON `null`, asserts 400 with `Request body must not be null`, and verifies no dispatcher interaction.
--
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] [#12608] feat(server): Add Semantic Model list, alter, and drop REST APIs [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao merged PR #12626:
URL: https://github.com/apache/gravitino/pull/12626
--
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] [#12608] feat(server): Add Semantic Model list, alter, and drop REST APIs [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12626:
URL: https://github.com/apache/gravitino/pull/12626#discussion_r4133797090
##########
common/src/main/java/org/apache/gravitino/dto/requests/SemanticModelUpdateRequest.java:
##########
@@ -0,0 +1,245 @@
+/*
+ * 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.
+ */
+package org.apache.gravitino.dto.requests;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.google.common.base.Preconditions;
+import javax.annotation.Nullable;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.dto.semantic.SemanticModelDefinitionDTO;
+import org.apache.gravitino.rest.RESTRequest;
+import org.apache.gravitino.semantic.SemanticModelChange;
+
+/** Represents one change in a request to alter a Semantic Model. */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)
+@JsonSubTypes({
+ @JsonSubTypes.Type(
+ value = SemanticModelUpdateRequest.RenameSemanticModelRequest.class,
+ name = "rename"),
+ @JsonSubTypes.Type(
+ value = SemanticModelUpdateRequest.UpdateSemanticModelCommentRequest.class,
+ name = "updateComment"),
+ @JsonSubTypes.Type(
+ value = SemanticModelUpdateRequest.SetSemanticModelPropertyRequest.class,
+ name = "setProperty"),
+ @JsonSubTypes.Type(
+ value = SemanticModelUpdateRequest.RemoveSemanticModelPropertyRequest.class,
+ name = "removeProperty"),
+ @JsonSubTypes.Type(
+ value = SemanticModelUpdateRequest.ReplaceSemanticModelDefinitionRequest.class,
+ name = "replaceDefinition")
+})
+public interface SemanticModelUpdateRequest extends RESTRequest {
+
+ /**
+ * Returns the Semantic Model change represented by this request.
+ *
+ * @return The Semantic Model change.
+ */
+ SemanticModelChange semanticModelChange();
+
+ /** Represents a request to rename a Semantic Model. */
+ @Getter
+ @EqualsAndHashCode
+ @ToString
+ class RenameSemanticModelRequest implements SemanticModelUpdateRequest {
+
+ @JsonProperty("newName")
+ private final String newName;
+
+ /** Default constructor for Jackson deserialization. */
+ public RenameSemanticModelRequest() {
+ this(null);
+ }
+
+ /**
+ * Creates a request to rename a Semantic Model.
+ *
+ * @param newName The new Semantic Model name.
+ */
+ public RenameSemanticModelRequest(String newName) {
+ this.newName = newName;
+ }
+
+ @Override
+ public void validate() throws IllegalArgumentException {
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(newName), "\"newName\" field is required and cannot be empty");
+ }
+
+ @Override
+ public SemanticModelChange semanticModelChange() {
+ return SemanticModelChange.rename(newName);
+ }
+ }
+
+ /** Represents a request to update a Semantic Model comment. */
+ @Getter
+ @EqualsAndHashCode
+ @ToString
+ class UpdateSemanticModelCommentRequest implements SemanticModelUpdateRequest {
+
+ @Nullable
+ @JsonProperty("newComment")
+ private final String newComment;
+
+ /** Default constructor for Jackson deserialization. */
+ public UpdateSemanticModelCommentRequest() {
+ this(null);
+ }
+
+ /**
+ * Creates a request to update or clear a Semantic Model comment.
+ *
+ * @param newComment The new comment, or {@code null} to clear it.
+ */
+ public UpdateSemanticModelCommentRequest(@Nullable String newComment) {
+ this.newComment = newComment;
+ }
+
+ @Override
+ public void validate() throws IllegalArgumentException {
+ // A null comment clears the current comment; an empty comment is stored as supplied.
+ }
+
+ @Override
+ public SemanticModelChange semanticModelChange() {
+ return SemanticModelChange.updateComment(newComment);
+ }
+ }
+
+ /** Represents a request to set a Semantic Model property. */
+ @Getter
+ @EqualsAndHashCode
+ @ToString
+ class SetSemanticModelPropertyRequest implements SemanticModelUpdateRequest {
+
+ @JsonProperty("property")
+ private final String property;
+
+ @JsonProperty("value")
+ private final String value;
+
+ /** Default constructor for Jackson deserialization. */
+ public SetSemanticModelPropertyRequest() {
+ this(null, null);
+ }
+
+ /**
+ * Creates a request to set a Semantic Model property.
+ *
+ * @param property The property name.
+ * @param value The property value.
+ */
+ public SetSemanticModelPropertyRequest(String property, String value) {
+ this.property = property;
+ this.value = value;
+ }
+
+ @Override
+ public void validate() throws IllegalArgumentException {
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(property), "\"property\" field is required and cannot be empty");
+ Preconditions.checkArgument(value != null, "\"value\" field is required and cannot be null");
+ }
+
+ @Override
+ public SemanticModelChange semanticModelChange() {
+ return SemanticModelChange.setProperty(property, value);
+ }
+ }
+
+ /** Represents a request to remove a Semantic Model property. */
+ @Getter
+ @EqualsAndHashCode
+ @ToString
+ class RemoveSemanticModelPropertyRequest implements SemanticModelUpdateRequest {
+
+ @JsonProperty("property")
+ private final String property;
+
+ /** Default constructor for Jackson deserialization. */
+ public RemoveSemanticModelPropertyRequest() {
+ this(null);
+ }
+
+ /**
+ * Creates a request to remove a Semantic Model property.
+ *
+ * @param property The property name.
+ */
+ public RemoveSemanticModelPropertyRequest(String property) {
+ this.property = property;
+ }
+
+ @Override
+ public void validate() throws IllegalArgumentException {
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(property), "\"property\" field is required and cannot be empty");
+ }
+
+ @Override
+ public SemanticModelChange semanticModelChange() {
+ return SemanticModelChange.removeProperty(property);
+ }
+ }
+
+ /** Represents a request to replace the complete Semantic Model definition. */
+ @Getter
+ @EqualsAndHashCode
+ @ToString
+ class ReplaceSemanticModelDefinitionRequest implements SemanticModelUpdateRequest {
+
+ @JsonProperty("definition")
+ private final SemanticModelDefinitionDTO definition;
+
+ /** Default constructor for Jackson deserialization. */
+ public ReplaceSemanticModelDefinitionRequest() {
+ this(null);
+ }
+
+ /**
+ * Creates a request to replace the complete Semantic Model definition.
+ *
+ * @param definition The replacement definition DTO.
+ */
+ public ReplaceSemanticModelDefinitionRequest(SemanticModelDefinitionDTO definition) {
+ this.definition = definition;
+ }
+
+ @Override
+ public void validate() throws IllegalArgumentException {
+ Preconditions.checkArgument(
+ definition != null, "\"definition\" field is required and cannot be null");
+ definition.toDefinition();
Review Comment:
Added stateless `SemanticModelDefinitionDTO.validate()` and switched `replaceDefinition` validation to use it in 410d754242. `semanticModelChange()` now performs the only DTO-to-API conversion and remains independent of a prior `validate()` call. The create path reuses the same validation.
--
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] [#12608] feat(server): Add Semantic Model list, alter, and drop REST APIs [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12626:
URL: https://github.com/apache/gravitino/pull/12626#discussion_r4121706695
##########
server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelOperations.java:
##########
@@ -63,6 +72,44 @@ public SemanticModelOperations(SemanticModelDispatcher dispatcher) {
this.dispatcher = dispatcher;
}
+ /**
+ * Lists Semantic Models in a schema.
+ *
+ * @param metalake The metalake name.
+ * @param catalog The catalog name.
+ * @param schema The schema name.
+ * @return A response containing Semantic Model identifiers.
+ */
+ @GET
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "list-semantic-model." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "list-semantic-model", absolute = true)
+ public Response listSemanticModels(
Review Comment:
`SemanticModelOperations` is not among the REST classes registered by `GravitinoInterceptionService`, and this method has no authorization annotations of its own. Consequently the new list endpoint is not intercepted at all, so an authenticated caller can enumerate Semantic Models in schemas they cannot access. Register this resource and add the appropriate schema/list authorization and metadata bindings.
This issue also appears on line 83 of the same file.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelOperations.java:
##########
@@ -63,6 +72,44 @@ public SemanticModelOperations(SemanticModelDispatcher dispatcher) {
this.dispatcher = dispatcher;
}
+ /**
+ * Lists Semantic Models in a schema.
+ *
+ * @param metalake The metalake name.
+ * @param catalog The catalog name.
+ * @param schema The schema name.
+ * @return A response containing Semantic Model identifiers.
+ */
+ @GET
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "list-semantic-model." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "list-semantic-model", absolute = true)
+ public Response listSemanticModels(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema) {
+ LOG.info(
+ "Received list Semantic Models request for schema: {}.{}.{}", metalake, catalog, schema);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ Namespace namespace = NamespaceUtil.ofSemanticModel(metalake, catalog, schema);
+ NameIdentifier[] identifiers = dispatcher.listSemanticModels(namespace);
+ identifiers = identifiers == null ? new NameIdentifier[0] : identifiers;
Review Comment:
This returns the complete dispatcher result without any authorization filtering. The Semantic Model authorization contract requires list/load to expose only models visible through SELECT/MODIFY/ownership, but this endpoint has no authorization annotation or `MetadataAuthzHelper` filter, so callers can enumerate unauthorized model names. Add the semantic-model list authorization expression and filter the identifiers before constructing `EntityListResponse`.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelOperations.java:
##########
@@ -157,4 +204,103 @@ public Response loadSemanticModel(
OperationType.LOAD, semanticModel, schema, e);
}
}
+
+ /**
+ * Alters a Semantic Model atomically.
+ *
+ * @param metalake The metalake name.
+ * @param catalog The catalog name.
+ * @param schema The schema name.
+ * @param semanticModel The current Semantic Model name.
+ * @param request The updates to apply.
+ * @return A response containing the altered Semantic Model.
+ */
+ @PUT
+ @Path("{semanticModel}")
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "alter-semantic-model." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "alter-semantic-model", absolute = true)
+ public Response alterSemanticModel(
Review Comment:
This new alter route has no authorization check, unlike the other schema-scoped metadata alter endpoints. A caller who can reach the REST resource can therefore rename, change properties, or replace a definition without the required MODIFY_SEMANTIC_MODEL privilege or ownership. Add the appropriate semantic-model authorization expression and authorization metadata to this method before dispatching the changes.
This issue also appears on line 269 of the same file.
--
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] [#12608] feat(server): Add Semantic Model list, alter, and drop REST APIs [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #12626:
URL: https://github.com/apache/gravitino/pull/12626#discussion_r4130815625
##########
common/src/main/java/org/apache/gravitino/dto/requests/SemanticModelUpdateRequest.java:
##########
@@ -0,0 +1,245 @@
+/*
+ * 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.
+ */
+package org.apache.gravitino.dto.requests;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.google.common.base.Preconditions;
+import javax.annotation.Nullable;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.dto.semantic.SemanticModelDefinitionDTO;
+import org.apache.gravitino.rest.RESTRequest;
+import org.apache.gravitino.semantic.SemanticModelChange;
+
+/** Represents one change in a request to alter a Semantic Model. */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)
+@JsonSubTypes({
+ @JsonSubTypes.Type(
+ value = SemanticModelUpdateRequest.RenameSemanticModelRequest.class,
+ name = "rename"),
+ @JsonSubTypes.Type(
+ value = SemanticModelUpdateRequest.UpdateSemanticModelCommentRequest.class,
+ name = "updateComment"),
+ @JsonSubTypes.Type(
+ value = SemanticModelUpdateRequest.SetSemanticModelPropertyRequest.class,
+ name = "setProperty"),
+ @JsonSubTypes.Type(
+ value = SemanticModelUpdateRequest.RemoveSemanticModelPropertyRequest.class,
+ name = "removeProperty"),
+ @JsonSubTypes.Type(
+ value = SemanticModelUpdateRequest.ReplaceSemanticModelDefinitionRequest.class,
+ name = "replaceDefinition")
+})
+public interface SemanticModelUpdateRequest extends RESTRequest {
+
+ /**
+ * Returns the Semantic Model change represented by this request.
+ *
+ * @return The Semantic Model change.
+ */
+ SemanticModelChange semanticModelChange();
+
+ /** Represents a request to rename a Semantic Model. */
+ @Getter
+ @EqualsAndHashCode
+ @ToString
+ class RenameSemanticModelRequest implements SemanticModelUpdateRequest {
+
+ @JsonProperty("newName")
+ private final String newName;
+
+ /** Default constructor for Jackson deserialization. */
+ public RenameSemanticModelRequest() {
+ this(null);
+ }
+
+ /**
+ * Creates a request to rename a Semantic Model.
+ *
+ * @param newName The new Semantic Model name.
+ */
+ public RenameSemanticModelRequest(String newName) {
+ this.newName = newName;
+ }
+
+ @Override
+ public void validate() throws IllegalArgumentException {
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(newName), "\"newName\" field is required and cannot be empty");
+ }
+
+ @Override
+ public SemanticModelChange semanticModelChange() {
+ return SemanticModelChange.rename(newName);
+ }
+ }
+
+ /** Represents a request to update a Semantic Model comment. */
+ @Getter
+ @EqualsAndHashCode
+ @ToString
+ class UpdateSemanticModelCommentRequest implements SemanticModelUpdateRequest {
+
+ @Nullable
+ @JsonProperty("newComment")
+ private final String newComment;
+
+ /** Default constructor for Jackson deserialization. */
+ public UpdateSemanticModelCommentRequest() {
+ this(null);
+ }
+
+ /**
+ * Creates a request to update or clear a Semantic Model comment.
+ *
+ * @param newComment The new comment, or {@code null} to clear it.
+ */
+ public UpdateSemanticModelCommentRequest(@Nullable String newComment) {
+ this.newComment = newComment;
+ }
+
+ @Override
+ public void validate() throws IllegalArgumentException {
+ // A null comment clears the current comment; an empty comment is stored as supplied.
+ }
+
+ @Override
+ public SemanticModelChange semanticModelChange() {
+ return SemanticModelChange.updateComment(newComment);
+ }
+ }
+
+ /** Represents a request to set a Semantic Model property. */
+ @Getter
+ @EqualsAndHashCode
+ @ToString
+ class SetSemanticModelPropertyRequest implements SemanticModelUpdateRequest {
+
+ @JsonProperty("property")
+ private final String property;
+
+ @JsonProperty("value")
+ private final String value;
+
+ /** Default constructor for Jackson deserialization. */
+ public SetSemanticModelPropertyRequest() {
+ this(null, null);
+ }
+
+ /**
+ * Creates a request to set a Semantic Model property.
+ *
+ * @param property The property name.
+ * @param value The property value.
+ */
+ public SetSemanticModelPropertyRequest(String property, String value) {
+ this.property = property;
+ this.value = value;
+ }
+
+ @Override
+ public void validate() throws IllegalArgumentException {
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(property), "\"property\" field is required and cannot be empty");
+ Preconditions.checkArgument(value != null, "\"value\" field is required and cannot be null");
+ }
+
+ @Override
+ public SemanticModelChange semanticModelChange() {
+ return SemanticModelChange.setProperty(property, value);
+ }
+ }
+
+ /** Represents a request to remove a Semantic Model property. */
+ @Getter
+ @EqualsAndHashCode
+ @ToString
+ class RemoveSemanticModelPropertyRequest implements SemanticModelUpdateRequest {
+
+ @JsonProperty("property")
+ private final String property;
+
+ /** Default constructor for Jackson deserialization. */
+ public RemoveSemanticModelPropertyRequest() {
+ this(null);
+ }
+
+ /**
+ * Creates a request to remove a Semantic Model property.
+ *
+ * @param property The property name.
+ */
+ public RemoveSemanticModelPropertyRequest(String property) {
+ this.property = property;
+ }
+
+ @Override
+ public void validate() throws IllegalArgumentException {
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(property), "\"property\" field is required and cannot be empty");
+ }
+
+ @Override
+ public SemanticModelChange semanticModelChange() {
+ return SemanticModelChange.removeProperty(property);
+ }
+ }
+
+ /** Represents a request to replace the complete Semantic Model definition. */
+ @Getter
+ @EqualsAndHashCode
+ @ToString
+ class ReplaceSemanticModelDefinitionRequest implements SemanticModelUpdateRequest {
+
+ @JsonProperty("definition")
+ private final SemanticModelDefinitionDTO definition;
+
+ /** Default constructor for Jackson deserialization. */
+ public ReplaceSemanticModelDefinitionRequest() {
+ this(null);
+ }
+
+ /**
+ * Creates a request to replace the complete Semantic Model definition.
+ *
+ * @param definition The replacement definition DTO.
+ */
+ public ReplaceSemanticModelDefinitionRequest(SemanticModelDefinitionDTO definition) {
+ this.definition = definition;
+ }
+
+ @Override
+ public void validate() throws IllegalArgumentException {
+ Preconditions.checkArgument(
+ definition != null, "\"definition\" field is required and cannot be null");
+ definition.toDefinition();
Review Comment:
[Nit] `toDefinition()` runs twice per `replaceDefinition` update: once here with the result discarded, then again in `semanticModelChange()` (line 242). For a definition with many datasets, fields and metrics that doubles the DTO-to-API conversion on every alter request.
Converting once and keeping the result would avoid it, e.g. validate into a field and return `SemanticModelChange.replaceDefinition(converted)` — with the caveat that `semanticModelChange()` then still needs to behave sensibly if it is ever called without `validate()` first. Purely a cleanup; the current behaviour is correct.
Verified by: read both methods in full and confirmed `SemanticModelOperations.alterSemanticModel:242-249` calls `validate()` and then `semanticModelChange()` on the same instances.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelOperations.java:
##########
@@ -157,4 +204,103 @@ public Response loadSemanticModel(
OperationType.LOAD, semanticModel, schema, e);
}
}
+
+ /**
+ * Alters a Semantic Model atomically.
+ *
+ * @param metalake The metalake name.
+ * @param catalog The catalog name.
+ * @param schema The schema name.
+ * @param semanticModel The current Semantic Model name.
+ * @param request The updates to apply.
+ * @return A response containing the altered Semantic Model.
+ */
+ @PUT
+ @Path("{semanticModel}")
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "alter-semantic-model." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "alter-semantic-model", absolute = true)
+ public Response alterSemanticModel(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema,
+ @PathParam("semanticModel") String semanticModel,
+ SemanticModelUpdatesRequest request) {
+ LOG.info(
+ "Received alter Semantic Model request: {}.{}.{}.{}",
+ metalake,
+ catalog,
+ schema,
+ semanticModel);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ if (request == null) {
+ throw new IllegalArgumentException("Request body must not be null");
+ }
Review Comment:
[Nit] This branch is not covered, unlike its counterpart on create. `testCreateSemanticModelRejectsNullBody` posts the literal body `null` through the `postJson` helper and asserts 400 plus `"Request body must not be null"` (`TestSemanticModelOperations.java:389-398`), but the new `put` helper only takes a typed `SemanticModelUpdatesRequest`, so a `null` alter body is never exercised.
A `putJson(path, "null")` helper mirroring `postJson`, plus one assertion, would close the gap and lock the 400 in place.
Verified by: read the full test file and both request helpers; grepped the test for null-body cases — only the create one exists.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelOperations.java:
##########
@@ -63,6 +72,44 @@ public SemanticModelOperations(SemanticModelDispatcher dispatcher) {
this.dispatcher = dispatcher;
}
+ /**
+ * Lists Semantic Models in a schema.
+ *
+ * @param metalake The metalake name.
+ * @param catalog The catalog name.
+ * @param schema The schema name.
+ * @return A response containing Semantic Model identifiers.
+ */
+ @GET
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "list-semantic-model." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "list-semantic-model", absolute = true)
+ public Response listSemanticModels(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema) {
+ LOG.info(
+ "Received list Semantic Models request for schema: {}.{}.{}", metalake, catalog, schema);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ Namespace namespace = NamespaceUtil.ofSemanticModel(metalake, catalog, schema);
+ NameIdentifier[] identifiers = dispatcher.listSemanticModels(namespace);
+ identifiers = identifiers == null ? new NameIdentifier[0] : identifiers;
Review Comment:
[Nit] This null fallback is unreachable and the test branch that pairs with it asserts behaviour no implementation can produce.
`SemanticModelCatalog.listSemanticModels` declares a plain `NameIdentifier[]` with no nullability allowance (`api/src/main/java/org/apache/gravitino/semantic/SemanticModelCatalog.java:35-42`), the merged core implementation always builds an array via `toArray(NameIdentifier[]::new)` (`core/.../ManagedSemanticModelOperations.java:75-87` on `origin/main`), and `SemanticModelNormalizeDispatcher` just forwards it. No other list endpoint in the server guards this — compare `ViewOperations.listViews`, which passes the dispatcher result straight into `EntityListResponse`.
Suggest dropping this line and the matching `thenReturn(null)` assertion in `TestSemanticModelOperations#testListSemanticModels`, so the dispatcher contract stays the single source of truth.
Verified by: read the API interface, both core implementations (PR head and `origin/main`), the normalize dispatcher, and `ViewOperations.listViews` in this run.
--
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] [#12608] feat(server): Add Semantic Model list, alter, and drop REST APIs [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12626:
URL: https://github.com/apache/gravitino/pull/12626#discussion_r4123013472
##########
server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelOperations.java:
##########
@@ -63,6 +72,44 @@ public SemanticModelOperations(SemanticModelDispatcher dispatcher) {
this.dispatcher = dispatcher;
}
+ /**
+ * Lists Semantic Models in a schema.
+ *
+ * @param metalake The metalake name.
+ * @param catalog The catalog name.
+ * @param schema The schema name.
+ * @return A response containing Semantic Model identifiers.
+ */
+ @GET
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "list-semantic-model." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "list-semantic-model", absolute = true)
+ public Response listSemanticModels(
Review Comment:
Authorization is outside the scope of this PR and is tracked in #12594. The REST authorization work in #13512 will be extended to cover the list, alter, and drop endpoints added here.
--
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] [#12608] feat(server): Add Semantic Model list, alter, and drop REST APIs [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12626:
URL: https://github.com/apache/gravitino/pull/12626#discussion_r4123064413
##########
server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelOperations.java:
##########
@@ -157,4 +204,103 @@ public Response loadSemanticModel(
OperationType.LOAD, semanticModel, schema, e);
}
}
+
+ /**
+ * Alters a Semantic Model atomically.
+ *
+ * @param metalake The metalake name.
+ * @param catalog The catalog name.
+ * @param schema The schema name.
+ * @param semanticModel The current Semantic Model name.
+ * @param request The updates to apply.
+ * @return A response containing the altered Semantic Model.
+ */
+ @PUT
+ @Path("{semanticModel}")
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "alter-semantic-model." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "alter-semantic-model", absolute = true)
+ public Response alterSemanticModel(
Review Comment:
Authorization for alter and drop is outside the scope of this PR and is tracked in #12594. After incorporating this PR, #13512 will apply `MODIFY_SEMANTIC_MODEL_AUTHORIZATION_EXPRESSION` to alter and the separate `DROP_SEMANTIC_MODEL_AUTHORIZATION_EXPRESSION` to drop, with the required authorization metadata.
--
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