Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#15250] docs: Document Semantic Model revisions and publication (#15254)

mchadesbadf1ef01d84
diff --git a/docs/gravitino-mcp-server.md b/docs/gravitino-mcp-server.md
index 616f38ea56..eda675bddf 100644
--- a/docs/gravitino-mcp-server.md
+++ b/docs/gravitino-mcp-server.md
@@ -143,6 +143,7 @@ Gravitino MCP server supports the following tools, and you could export tool by
| `list_metric_infos` | List complete visible metrics across Semantic Models in a schema. | `semantic_model` |
| `list_semantic_model_datasets` | List visible datasets directly associated with a source table or view. | `semantic_model` |
| `load_semantic_model` | Load a Semantic Model's metadata and definition. | `semantic_model` |
+| `list_semantic_model_revisions` | List visible retained revisions newest first. | `semantic_model` |
| `create_semantic_model` | Create a Semantic Model from a native REST definition. | `semantic_model` |
| `alter_semantic_model` | Apply Semantic Model updates atomically. | `semantic_model` |
| `drop_semantic_model` | Drop a Semantic Model's metadata. | `semantic_model` |
@@ -234,13 +235,19 @@ For example, call `create_semantic_model` with the following arguments after the
non-empty `datasets` array and supports optional `relationships`, `metrics`,
`aiContext`, and `customExtensions` fields.
`comment` and `properties` are optional. Load, create, and alter return the model object
-with its definition, properties, and audit information.
+with its definition, properties, audit information, revision, and publication status.
+`load_semantic_model` uses the active revision by default. Pass a positive revision number or
+`"latest"` as `revision` to load a saved revision. Use `list_semantic_model_revisions` to
+read revision summaries, including publisher details for published revisions. Drafts require
+modify access.
`alter_semantic_model` accepts `catalog_name`, `schema_name`, `semantic_model_name`, and
an ordered, non-empty `updates` array. Supported `@type` values are `rename`,
`updateComment`, `setProperty`, `removeProperty`, and `replaceDefinition`. For example,
`[{"@type": "updateComment", "newComment": null}]` clears the comment.
-`replaceDefinition` requires the complete native definition and revalidates source access.
+Send `rename` on its own. `replaceDefinition` requires the complete native definition and
+revalidates source access. Load `"latest"`, then pass the returned revision as `expected_revision`.
+On a conflict, reload, reapply the edits, and retry.
`drop_semantic_model` takes the model's catalog, schema, and name and returns a JSON boolean
indicating whether it was dropped. It removes semantic metadata without deleting source tables or data.
diff --git a/docs/gravitino-server-config.md b/docs/gravitino-server-config.md
index bde0078fc3..3f0d0eb4c1 100644
--- a/docs/gravitino-server-config.md
+++ b/docs/gravitino-server-config.md
@@ -338,7 +338,8 @@ The driver, user, and password properties are required whenever the URL is not `
| `gravitino.entity.store.relational.maxWaitMillis` | Maximum wait in milliseconds for a connection from the pool. | `1000` |
| `gravitino.entity.store.maxTransactionSkewTimeMs` | Maximum transaction skew in milliseconds. | `2000` |
| `gravitino.entity.store.deleteAfterTimeMs` | How long in milliseconds deleted and superseded rows are kept. Accepts 10 minutes to 30 days. | `604800000` (7 days) |
-| `gravitino.entity.store.versionRetentionCount` | Number of entity versions kept, including the current one. Accepts 1 to 10. | `1` |
+| `gravitino.entity.store.versionRetentionCount` | Number of entity versions kept, including the current one. Accepts 1 to 10. Semantic Models use their own setting. | `1` |
+| `gravitino.entity.store.semanticModel.versionRetentionCount` | Number of newest Semantic Model revisions kept per model. Accepts 1 to 1000. Active and explicitly published revisions are kept independently. | `100` |
#### Caching
diff --git a/docs/manage-semantic-model-metadata-using-gravitino.md b/docs/manage-semantic-model-metadata-using-gravitino.md
index c1631d765d..e1a9dcafaf 100644
--- a/docs/manage-semantic-model-metadata-using-gravitino.md
+++ b/docs/manage-semantic-model-metadata-using-gravitino.md
@@ -586,8 +586,8 @@ includes metrics only from models the caller can discover through `USE_SEMANTIC_
[Ownership and Privileges](#ownership-and-privileges). Discovery does not revalidate access to
source tables or views and does not grant access to source data.
-Discovery reflects each model's current committed definition: renaming a model changes the
-namespace returned for its metrics, replacing its definition changes the discovered metrics,
+Discovery reflects each model's active revision: renaming a model changes the
+namespace returned for its metrics, publishing a definition changes the discovered metrics,
and dropping it removes its metrics from discovery. Manage metric definitions through their
containing Semantic Models; discovery does not provide a separate metric lifecycle or execute
metric expressions.
@@ -600,8 +600,9 @@ for response and error details.
### Alter a Semantic Model
-Changes are applied in order in one request. If any change or the resulting model is invalid, none
-of the changes is persisted.
+Changes apply in order to the latest saved revision. A rename must be sent on its own, updates the
+model name immediately, and creates no revision. Comment, property, and definition changes save a
+new revision.
| Change | REST update |
|--------|-------------|
@@ -647,10 +648,49 @@ altered = models.alter_semantic_model(
</TabItem>
</Tabs>
-Definition replacement replaces all datasets, relationships, and metrics. Include everything you
-want to retain. In Java, use `SemanticModelChange.replaceDefinition(definition)`; in Python, use
-`SemanticModelChange.replace_definition(definition)`. Each replacement revalidates the complete
-definition and its source access. Comment and property changes do not revalidate sources.
+A definition replacement includes the complete definition and revalidates its sources. Load
+`latest` to prepare an edit, then send its revision as `expectedRevision`. Java passes this number
+before the change arguments, and Python uses the keyword `expected_revision`. On HTTP 409
+(`OptimisticLockException`), reload latest and reapply the edit. You can also supply this
+precondition for a comment, property, or rename request.
+
+### Read and Export Revision History
+
+A regular load or Ossie export uses the active revision. By default every save publishes
+immediately. A deployment with a deferred publication policy saves drafts and keeps the previous
+published revision active. With authorization enabled, only callers with modify access can see
+drafts in the revision history. If `latest` is a draft, `GET /revisions/latest` returns HTTP 404
+to a read-only caller. The regular model URL returns the active revision when one exists.
+Each model keeps its newest 100 revisions by default. The server setting
+`gravitino.entity.store.semanticModel.versionRetentionCount` accepts 1 through 1000.
+The active revision is always retained. Explicitly published revisions stay readable for the
+lifetime of the model.
+
+Relative to the Semantic Model URL, use `GET /revisions` to list summaries newest first,
+`GET /revisions/latest` to load the newest save, and `GET /revisions/7` to load revision 7.
+Append `/ossie?format=json` to export a selected revision as JSON. The response metadata
+includes `revision` and `status`, and published revisions report `publishedBy` and `publishedAt`.
+History also returns the writer's audit information. Use a previously retained definition in a
+conditional alter to restore it as a new revision.
+
+```java
+SemanticModel latest = models.loadSemanticModel(ident, SemanticModelCatalog.LATEST_REVISION);
+SemanticModelRevision[] history = models.listSemanticModelRevisions(ident);
+OssieDocument old = models.exportOssieDocument(ident, 1, OssieFormat.YAML);
+models.alterSemanticModel(
+ ident, latest.revision(), SemanticModelChange.replaceDefinition(definition));
+```
+
+```python
+latest = models.load_semantic_model(ident, revision="latest")
+history = models.list_semantic_model_revisions(ident)
+old = models.export_ossie_document(ident, revision=1)
+models.alter_semantic_model(
+ ident,
+ SemanticModelChange.replace_definition(definition),
+ expected_revision=latest.revision(),
+)
+```
## Apache Ossie Import and Export
@@ -883,8 +923,9 @@ An authorized request for an absent model returns `false` (`dropped: false` in R
The [Gravitino MCP server](./gravitino-mcp-server.md#semantic-models) provides
`list_of_semantic_models`, `load_semantic_model`, `create_semantic_model`, `alter_semantic_model`,
-`drop_semantic_model`, `list_metrics`, `list_metric_infos`, and `list_semantic_model_datasets`.
+`drop_semantic_model`, `list_metrics`, `list_metric_infos`, `list_semantic_model_datasets`,
+and `list_semantic_model_revisions`.
Enable the `semantic_model` tool tag when filtering tools. Metric discovery tools return the same
full namespaces as REST.
Create and alter use the native REST definition format. Use REST or the SDKs for Ossie import and
-export. The current Web UI does not provide Semantic Model workflows.
+export.
diff --git a/docs/open-api/openapi.yaml b/docs/open-api/openapi.yaml
index 633518e233..fbe1a6f5be 100644
--- a/docs/open-api/openapi.yaml
+++ b/docs/open-api/openapi.yaml
@@ -186,6 +186,15 @@ paths:
/metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/semantic-models/{semanticModel}/ossie:
$ref: "./semantic-models.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1catalogs~1%7Bcatalog%7D~1schemas~1%7Bschema%7D~1semantic-models~1%7BsemanticModel%7D~1ossie"
+ /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/semantic-models/{semanticModel}/revisions:
+ $ref: "./semantic-models.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1catalogs~1%7Bcatalog%7D~1schemas~1%7Bschema%7D~1semantic-models~1%7BsemanticModel%7D~1revisions"
+
+ /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/semantic-models/{semanticModel}/revisions/{revision}:
+ $ref: "./semantic-models.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1catalogs~1%7Bcatalog%7D~1schemas~1%7Bschema%7D~1semantic-models~1%7BsemanticModel%7D~1revisions~1%7Brevision%7D"
+
+ /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/semantic-models/{semanticModel}/revisions/{revision}/ossie:
+ $ref: "./semantic-models.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1catalogs~1%7Bcatalog%7D~1schemas~1%7Bschema%7D~1semantic-models~1%7BsemanticModel%7D~1revisions~1%7Brevision%7D~1ossie"
+
/metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/functions:
$ref: "./functions.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1catalogs~1%7Bcatalog%7D~1schemas~1%7Bschema%7D~1functions"
diff --git a/docs/open-api/semantic-models.yaml b/docs/open-api/semantic-models.yaml
index 89a6f82458..a2833be810 100644
--- a/docs/open-api/semantic-models.yaml
+++ b/docs/open-api/semantic-models.yaml
@@ -45,7 +45,7 @@ paths:
database collation. Dataset names containing dots remain a single name component.
An existing source with no visible matches returns an empty identifiers array; missing
sources and storage failures fail the request. The response is unpaginated.
- Associations refer to source IDs resolved at the latest definition write. Renaming a source
+ Associations refer to source IDs resolved for the active revision. Renaming a source
while preserving its ID keeps its associations; reusing its name for a new source does not.
This lookup neither rewrites nor revalidates model definitions and does not follow View
dependencies. The source full name uses catalog.schema.name; literal dots in source name
@@ -77,7 +77,7 @@ paths:
- semantic-model
summary: List metrics across Semantic Models
description: >-
- Lists metrics in the current committed definitions of live Semantic Models in a schema.
+ Lists metrics in the active revisions of published Semantic Models in a schema.
Supported only for relational catalogs. With details=false (the default), returns metric
identifiers; with details=true, returns complete metric definitions and their namespaces.
Namespaces contain [metalake, catalog, schema, semanticModel]. Both modes require schema
@@ -254,7 +254,7 @@ paths:
tags:
- semantic-model
summary: Load a Semantic Model
- description: Returns the specified Semantic Model with its nested definition and audit data.
+ description: Returns the active revision with its nested definition, publication metadata, and audit data.
operationId: loadSemanticModel
responses:
"200":
@@ -280,7 +280,9 @@ paths:
updates is applied. Each replaceDefinition revalidates the complete definition, source
existence, and primary-key, unique-key, and relationship columns. When authorization is
enabled, source lookups also require the caller's permission to access the source metadata.
- Metadata-only updates do not revalidate sources.
+ Metadata-only updates do not revalidate sources. expectedRevision is required for a
+ definition replacement and otherwise optional. If provided, it must match the latest
+ saved revision. A rename must be the only update and does not create a new revision.
operationId: alterSemanticModel
requestBody:
required: true
@@ -354,7 +356,7 @@ paths:
- semantic-model
summary: Export a Semantic Model as an Apache Ossie document
description: >-
- Exports the specified Semantic Model as a standalone Apache Ossie YAML or JSON document.
+ Exports the active revision as a standalone Apache Ossie YAML or JSON document.
The response is downloadable document content rather than the native Gravitino response
envelope. The format query parameter selects the representation independently of the
Accept header.
@@ -384,7 +386,107 @@ paths:
"5XX":
$ref: "./openapi.yaml#/components/responses/ServerErrorResponse"
+ /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/semantic-models/{semanticModel}/revisions:
+ parameters:
+ - $ref: "./openapi.yaml#/components/parameters/metalake"
+ - $ref: "./openapi.yaml#/components/parameters/catalog"
+ - $ref: "./openapi.yaml#/components/parameters/schema"
+ - $ref: "./openapi.yaml#/components/parameters/semanticModel"
+
+ get:
+ tags:
+ - semantic-model
+ summary: List retained Semantic Model revisions
+ description: Returns revision summaries newest first. Drafts require modify authority.
+ operationId: listSemanticModelRevisions
+ responses:
+ "200":
+ $ref: "#/components/responses/SemanticModelRevisionListResponse"
+ "400":
+ $ref: "#/components/responses/SemanticModelBadRequestResponse"
+ "403":
+ $ref: "#/components/responses/SemanticModelForbiddenResponse"
+ "404":
+ $ref: "#/components/responses/SemanticModelRevisionNotFoundResponse"
+ "501":
+ $ref: "#/components/responses/SemanticModelUnsupportedCatalogResponse"
+ "5XX":
+ $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"
+
+ /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/semantic-models/{semanticModel}/revisions/{revision}:
+ parameters:
+ - $ref: "./openapi.yaml#/components/parameters/metalake"
+ - $ref: "./openapi.yaml#/components/parameters/catalog"
+ - $ref: "./openapi.yaml#/components/parameters/schema"
+ - $ref: "./openapi.yaml#/components/parameters/semanticModel"
+ - $ref: "#/components/parameters/semanticModelRevision"
+
+ get:
+ tags:
+ - semantic-model
+ summary: Load a Semantic Model revision
+ description: Loads a positive revision number or latest. Drafts require modify authority.
+ operationId: loadSemanticModelRevision
+ responses:
+ "200":
+ $ref: "#/components/responses/SemanticModelResponse"
+ "400":
+ $ref: "#/components/responses/SemanticModelBadRequestResponse"
+ "403":
+ $ref: "#/components/responses/SemanticModelForbiddenResponse"
+ "404":
+ $ref: "#/components/responses/SemanticModelRevisionNotFoundResponse"
+ "501":
+ $ref: "#/components/responses/SemanticModelUnsupportedCatalogResponse"
+ "5XX":
+ $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"
+
+ /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/semantic-models/{semanticModel}/revisions/{revision}/ossie:
+ parameters:
+ - $ref: "./openapi.yaml#/components/parameters/metalake"
+ - $ref: "./openapi.yaml#/components/parameters/catalog"
+ - $ref: "./openapi.yaml#/components/parameters/schema"
+ - $ref: "./openapi.yaml#/components/parameters/semanticModel"
+ - $ref: "#/components/parameters/semanticModelRevision"
+
+ get:
+ tags:
+ - semantic-model
+ summary: Export a Semantic Model revision
+ description: Exports the selected revision as an Ossie document. Drafts require modify authority.
+ operationId: exportSemanticModelRevision
+ parameters:
+ - name: format
+ in: query
+ description: The serialized document format
+ schema:
+ type: string
+ enum: [yaml, json]
+ default: yaml
+ responses:
+ "200":
+ $ref: "#/components/responses/OssieSemanticModelDocumentResponse"
+ "400":
+ $ref: "#/components/responses/SemanticModelBadRequestResponse"
+ "403":
+ $ref: "#/components/responses/SemanticModelForbiddenResponse"
+ "404":
+ $ref: "#/components/responses/SemanticModelRevisionNotFoundResponse"
+ "501":
+ $ref: "#/components/responses/SemanticModelUnsupportedCatalogResponse"
+ "5XX":
+ $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"
+
components:
+ parameters:
+ semanticModelRevision:
+ name: revision
+ in: path
+ required: true
+ description: A positive revision number or the alias latest
+ schema:
+ type: string
+ pattern: '^(latest|0*[1-9][0-9]*)$'
schemas:
SemanticModelMetric:
@@ -1041,10 +1143,28 @@ components:
description: A schema-scoped analytical Semantic Model with a nested semantic definition
required:
- name
+ - revision
+ - status
- definition
- properties
- audit
properties:
+ revision:
+ type: integer
+ format: int32
+ minimum: 1
+ description: The saved revision number
+ status:
+ type: string
+ enum: [DRAFT, PUBLISHED]
+ description: Whether this revision has been published
+ publishedBy:
+ type: string
+ description: The publishing principal. Omitted for drafts.
+ publishedAt:
+ type: string
+ format: date-time
+ description: The publication time. Omitted for drafts.
name:
type: string
minLength: 1
@@ -1064,6 +1184,31 @@ components:
$ref: "./openapi.yaml#/components/schemas/Audit"
additionalProperties: false
+ SemanticModelRevision:
+ type: object
+ description: Metadata of a retained revision
+ required: [revision, status, audit]
+ properties:
+ revision:
+ type: integer
+ format: int32
+ minimum: 1
+ description: The saved revision number
+ status:
+ type: string
+ enum: [DRAFT, PUBLISHED]
+ description: Whether this revision has been published
+ publishedBy:
+ type: string
+ description: The publishing principal. Omitted for drafts.
+ publishedAt:
+ type: string
+ format: date-time
+ description: The publication time. Omitted for drafts.
+ audit:
+ $ref: "./openapi.yaml#/components/schemas/Audit"
+ additionalProperties: false
+
SemanticModelCreateRequest:
type: object
description: The request to create a Semantic Model
@@ -1097,6 +1242,11 @@ components:
required:
- updates
properties:
+ expectedRevision:
+ type: integer
+ format: int32
+ minimum: 1
+ description: The expected latest revision. Required for replaceDefinition.
updates:
type: array
minItems: 1
@@ -1366,6 +1516,31 @@ components:
SemanticModelResponse:
$ref: "#/components/examples/SemanticModelResponse"
+ SemanticModelRevisionListResponse:
+ description: Visible retained revision summaries, newest first
+ content:
+ application/vnd.gravitino.v1+json:
+ schema:
+ type: object
+ required: [code, revisions]
+ properties:
+ code:
+ type: integer
+ format: int32
+ enum: [0]
+ revisions:
+ type: array
+ items:
+ $ref: "#/components/schemas/SemanticModelRevision"
+ additionalProperties: false
+
+ SemanticModelRevisionNotFoundResponse:
+ description: The model or revision is missing, the revision was collected, or the draft is hidden
+ content:
+ application/vnd.gravitino.v1+json:
+ schema:
+ $ref: "./openapi.yaml#/components/schemas/ErrorModel"
+
OssieSemanticModelDocumentResponse:
description: Returns a standalone Apache Ossie document in the requested format
headers:
@@ -1464,8 +1639,8 @@ components:
SemanticModelAlterConflictResponse:
description: >-
- Conflict - A rename target already exists or the internal transaction lost an
- optimistic-lock race
+ Conflict - The rename target already exists, expectedRevision differs from the latest
+ saved revision, or a concurrent change prevented the update from committing
content:
application/vnd.gravitino.v1+json:
schema:
@@ -1715,11 +1890,8 @@ components:
SemanticModelUpdatesRequest:
value: {
+ "expectedRevision": 1,
"updates": [
- {
- "@type": "rename",
- "newName": "sales_model_v2"
- },
{
"@type": "updateComment",
"newComment": ""
@@ -1758,6 +1930,10 @@ components:
value: {
"code": 0,
"semanticModel": {
+ "revision": 2,
+ "status": "PUBLISHED",
+ "publishedBy": "gravitino",
+ "publishedAt": "2026-01-02T00:00:00Z",
"name": "sales_model",
"comment": "Governed sales definitions",
"definition": {