World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
title: "Manage Semantic Model Metadata" slug: "/manage-semantic-model-metadata-using-gravitino" keyword: "semantic model management, semantic metadata, Ossie, Gravitino" license: "This software is licensed under the Apache License version 2."
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
Introduction
This page covers the Gravitino API for Semantic Models. For what a model contains, how its sources are validated, and how it relates to tables and views, see Semantic Models. For creating the catalog and schema a model lives in, see Manage Catalogs and Schemas.
Before You Start
The examples use the 2.0.0 server and clients. They assume:
- A server at
http://localhost:8090and an existing metalake namedexample. - A relational catalog named
sales, with a schema namedmart. - An existing source table
sales.mart.orderswithorder_id,customer_id, andorder_amountcolumns. - An existing source table
sales.mart.customerswithcustomer_idandcustomer_codecolumns.
See Manage Relational Metadata to create the source tables. Add the credentials required by your deployment as described in Authentication. With authorization enabled, the caller also needs the model and source privileges.
Choose one language tab and follow its examples. Each language manages the same model names, so running create or import again in another language reports that the model already exists. Run the drop examples when you have finished.
Java and Python model identifiers are relative to the loaded catalog (schema.model). Dataset
sources use catalog.schema.object within the same metalake. For SDK configuration, see
Client Setup and Python Client.
Java and Python client setup and imports
Place the operation snippets inside the client block below. The block closes the client when
finished; Java file operations also require the calling method to handle or declare IOException.
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import org.apache.gravitino.Catalog;
import org.apache.gravitino.NameIdentifier;
import org.apache.gravitino.Namespace;
import org.apache.gravitino.client.GravitinoClient;
import org.apache.gravitino.rel.Table;
import org.apache.gravitino.semantic.DataType;
import org.apache.gravitino.semantic.Dataset;
import org.apache.gravitino.semantic.DialectExpression;
import org.apache.gravitino.semantic.Dialects;
import org.apache.gravitino.semantic.Expression;
import org.apache.gravitino.semantic.Field;
import org.apache.gravitino.semantic.Metric;
import org.apache.gravitino.semantic.OssieDocument;
import org.apache.gravitino.semantic.OssieFormat;
import org.apache.gravitino.semantic.Relationship;
import org.apache.gravitino.semantic.SemanticModel;
import org.apache.gravitino.semantic.SemanticModelCatalog;
import org.apache.gravitino.semantic.SemanticModelChange;
import org.apache.gravitino.semantic.SemanticModelDefinition;
import org.apache.gravitino.semantic.SemanticModelMetric;
try (GravitinoClient client = GravitinoClient.builder("http://localhost:8090")
.withMetalake("example").build()) {
Catalog catalog = client.loadCatalog("sales");
SemanticModelCatalog models = catalog.asSemanticModelCatalog();
NameIdentifier ident = NameIdentifier.of("mart", "sales_model");
// Run the Java operation examples here.
}
from pathlib import Path
from gravitino import GravitinoClient, NameIdentifier
from gravitino.api.semantic.data_type import DataType
from gravitino.api.semantic.dataset import Dataset
from gravitino.api.semantic.dialect_expression import DialectExpression
from gravitino.api.semantic.dialects import Dialects
from gravitino.api.semantic.expression import Expression
from gravitino.api.semantic.field import Field
from gravitino.api.semantic.metric import Metric
from gravitino.api.semantic.relationship import Relationship
from gravitino.api.semantic.semantic_model_change import SemanticModelChange
from gravitino.api.semantic.semantic_model_definition import SemanticModelDefinition
from gravitino.namespace import Namespace
client = GravitinoClient(uri="http://localhost:8090", metalake_name="example")
try:
catalog = client.load_catalog("sales")
models = catalog.as_semantic_model_catalog()
ident = NameIdentifier.of("mart", "sales_model")
# Run the Python operation examples here.
finally:
client.close()
Semantic Model Operations
Create a Semantic Model
A model needs a name and a definition with at least one dataset. This example defines a revenue
metric over orders and links orders to customers by customer_id. The native REST API nests the
definition under definition. Its field names include primaryKey and datatype.
The relationship's from and to name datasets in the model. Its column lists and the datasets'
keys name fields declared in fields by the referenced datasets, not columns of the source
tables. Each array inside uniqueKeys defines one unique key.
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"name": "sales_model",
"comment": "Governed sales definitions",
"properties": {"domain": "sales"},
"definition": {
"datasets": [
{
"name": "orders",
"source": {"namespace": ["sales", "mart"], "name": "orders"},
"primaryKey": ["order_id"],
"fields": [
{
"name": "order_amount",
"expression": {
"dialects": [{"dialect": "ANSI_SQL", "expression": "order_amount"}]
},
"datatype": "Decimal"
},
{
"name": "order_id",
"expression": {
"dialects": [{"dialect": "ANSI_SQL", "expression": "order_id"}]
}
},
{
"name": "customer_id",
"expression": {
"dialects": [{"dialect": "ANSI_SQL", "expression": "customer_id"}]
}
}
]
},
{
"name": "customers",
"source": {"namespace": ["sales", "mart"], "name": "customers"},
"primaryKey": ["customer_id"],
"uniqueKeys": [["customer_code"]],
"fields": [
{
"name": "customer_id",
"expression": {
"dialects": [{"dialect": "ANSI_SQL", "expression": "customer_id"}]
}
},
{
"name": "customer_code",
"expression": {
"dialects": [{"dialect": "ANSI_SQL", "expression": "customer_code"}]
}
}
]
}
],
"relationships": [
{
"name": "orders_to_customers",
"from": "orders",
"to": "customers",
"fromColumns": ["customer_id"],
"toColumns": ["customer_id"]
}
],
"metrics": [
{
"name": "total_revenue",
"expression": {
"dialects": [{"dialect": "ANSI_SQL", "expression": "SUM(orders.order_amount)"}]
},
"datatype": "Decimal"
}
]
}
}' http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/mart/semantic-models
Expression amountExpression = Expression.builder()
.withDialects(new DialectExpression[] {
DialectExpression.builder().withDialect(Dialects.ANSI_SQL)
.withExpression("order_amount").build()
}).build();
Field amount = Field.builder().withName("order_amount")
.withExpression(amountExpression).withDatatype(DataType.DECIMAL).build();
// Key and join fields only need a name and an expression over the source columns.
private static Expression keyExpression(String column) {
return Expression.builder()
.withDialects(new DialectExpression[] {
DialectExpression.builder().withDialect(Dialects.ANSI_SQL)
.withExpression(column).build()
}).build();
}
Field orderId = Field.builder().withName("order_id")
.withExpression(keyExpression("order_id")).build();
Field orderCustomer = Field.builder().withName("customer_id")
.withExpression(keyExpression("customer_id")).build();
Field customerId = Field.builder().withName("customer_id")
.withExpression(keyExpression("customer_id")).build();
Field customerCode = Field.builder().withName("customer_code")
.withExpression(keyExpression("customer_code")).build();
Dataset orders = Dataset.builder().withName("orders")
.withSource(NameIdentifier.of("sales", "mart", "orders"))
.withPrimaryKey(new String[] {"order_id"})
.withFields(new Field[] {amount, orderId, orderCustomer})
.build();
Dataset customers = Dataset.builder().withName("customers")
.withSource(NameIdentifier.of("sales", "mart", "customers"))
.withPrimaryKey(new String[] {"customer_id"})
.withUniqueKeys(new String[][] {{"customer_code"}})
.withFields(new Field[] {customerId, customerCode})
.build();
Relationship ordersToCustomers = Relationship.builder().withName("orders_to_customers")
.withFrom("orders").withTo("customers")
.withFromColumns(new String[] {"customer_id"})
.withToColumns(new String[] {"customer_id"}).build();
Expression revenueExpression = Expression.builder()
.withDialects(new DialectExpression[] {
DialectExpression.builder().withDialect(Dialects.ANSI_SQL)
.withExpression("SUM(orders.order_amount)").build()
}).build();
Metric revenue = Metric.builder().withName("total_revenue")
.withExpression(revenueExpression).withDatatype(DataType.DECIMAL).build();
SemanticModelDefinition definition = SemanticModelDefinition.builder()
.withDatasets(new Dataset[] {orders, customers})
.withRelationships(new Relationship[] {ordersToCustomers})
.withMetrics(new Metric[] {revenue}).build();
SemanticModel created = models.createSemanticModel(
ident, "Governed sales definitions", definition, Map.of("domain", "sales"));
amount = Field(
"order_amount",
Expression([DialectExpression(Dialects.ANSI_SQL, "order_amount")]),
datatype=DataType.DECIMAL)
def key_field(name):
return Field(name, Expression([DialectExpression(Dialects.ANSI_SQL, name)]))
orders = Dataset(
"orders",
NameIdentifier.of("sales", "mart", "orders"),
primary_key=["order_id"],
fields=[amount, key_field("order_id"), key_field("customer_id")])
customers = Dataset(
"customers",
NameIdentifier.of("sales", "mart", "customers"),
primary_key=["customer_id"],
unique_keys=[["customer_code"]],
fields=[key_field("customer_id"), key_field("customer_code")])
orders_to_customers = Relationship(
"orders_to_customers",
from_dataset="orders",
to_dataset="customers",
from_columns=["customer_id"],
to_columns=["customer_id"])
revenue = Metric(
"total_revenue",
Expression([DialectExpression(Dialects.ANSI_SQL, "SUM(orders.order_amount)")]),
datatype=DataType.DECIMAL)
definition = SemanticModelDefinition(
datasets=[orders, customers],
relationships=[orders_to_customers],
metrics=[revenue])
created = models.create_semantic_model(
ident, "Governed sales definitions", definition, {"domain": "sales"})
The REST response contains code: 0 and a semanticModel object with name, comment,
properties, definition, and audit. The SDKs return a SemanticModel directly. Creating a name
that already exists reports a conflict without overwriting the model.
List Semantic Models
Listing returns identifiers rather than complete definitions. With authorization enabled, it includes only models visible to the caller.
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/mart/semantic-models
NameIdentifier[] identifiers = models.listSemanticModels(Namespace.of("mart"));
identifiers = models.list_semantic_models(Namespace.of("mart"))
REST identifiers include the namespace ["example", "sales", "mart"]. SDK identifiers are relative
to the loaded catalog, such as mart.sales_model.
Find Semantic Model Datasets by Source
A table or View can list its directly associated datasets across catalogs and schemas in the same metalake. The caller needs access to the source metadata. Results include only datasets from models the caller can load, with the same catalog and schema access requirements as loading those models.
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/objects/table/sales.mart.orders/semantic-model-datasets
Use view instead of table for a View, and URL-encode the source's catalog.schema.name path
component when needed. Other source types are rejected.
Table source = catalog.asTableCatalog().loadTable(NameIdentifier.of("mart", "orders"));
NameIdentifier[] datasets = source.supportsSemanticModels().listSemanticModelDatasets();
// A View returned by catalog.asViewCatalog().loadView(...) exposes the same capability.
source = catalog.as_table_catalog().load_table(NameIdentifier.of("mart", "orders"))
datasets = source.supports_semantic_models().list_semantic_model_datasets()
# A View returned by catalog.as_view_catalog().load_view(...) exposes the same capability.
All three APIs return fully qualified identifiers, including the metalake and catalog. For example:
{
"code": 0,
"identifiers": [
{"namespace": ["example", "sales", "mart", "sales_model"], "name": "orders"}
]
}
- Each identifier's namespace is
[metalake, catalog, schema, semanticModel];nameis the exact dataset alias in the model. Several datasets in one model can reference the same source and each appears separately. Preserve these components: a dataset name such asorders.rawis one name. - Results are unique and sorted by namespace components, then dataset name, comparing each component case-sensitively by UTF-16 code units. Clients preserve that server order. An existing source with no visible matches returns an empty array. Missing sources and failed queries return errors.
- To list models only, derive model identifiers from the dataset namespaces and remove duplicates.
In Java, use
NameIdentifier.of(dataset.namespace().levels()); in Python, useNameIdentifier.of(*dataset.namespace().levels()). Select each result's catalog before loading its model through the catalog-scoped API.
Associations are stored atomically with a model definition. Creating or importing a model, and explicitly replacing its definition, binds each dataset to the registered source ID resolved during source validation. A replacement refreshes the binding even if the definition text is unchanged. Model rename, comment, and property updates preserve existing bindings.
The lookup has these limits:
- Source names can drift. Renaming a source while preserving its registered ID retains the
association, but does not rewrite
Dataset.source. Inspect and explicitly replace affected model definitions when repairing references; a match does not prove that a model can execute. - Source name reuse does not transfer associations. Dropping and recreating a source gives it a different ID. The new source has no inherited matches. Explicitly replace a model's definition to validate and bind it to the new source, if that is the intended reference.
- Only current direct associations are indexed. View dependencies are not followed, and old model snapshots do not retain historical associations. Models written before this feature have no indexed bindings until an authorized definition replacement; there is no automatic backfill.
- Source addressing uses the existing object API format. Literal dots in source namespace components have the same ambiguity as other metadata-object relationship routes. Dataset names in the response do not have that restriction.
For MCP usage, see the
list_semantic_model_datasets tool.
Load a Semantic Model
Load returns the stored definition, properties, comment, and audit information.
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/mart/semantic-models/sales_model
SemanticModel loaded = models.loadSemanticModel(ident);
loaded = models.load_semantic_model(ident)
Discover Metrics in a Schema
Use schema-level metric discovery to find metrics across the current definitions of Semantic
Models in one schema. You can list identifiers or retrieve complete metric definitions without
first listing and loading each model. These examples use the total_revenue metric in
mart.sales_model created above, before importing any other models.
List Metric Identifiers
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
'http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/mart/semantic-model-metrics'
The default is details=false; only true (case-insensitive) enables complete metric definitions.
If sales_model is the only model with metrics in this schema, the default response is:
{
"code": 0,
"identifiers": [
{
"namespace": ["example", "sales", "mart", "sales_model"],
"name": "total_revenue"
}
]
}
NameIdentifier[] metricIdentifiers = models.listMetrics(Namespace.of("mart"));
metric_identifiers = models.list_metrics(Namespace.of("mart"))
Metric names are unique within a model. Two models can both define total_revenue; use the
namespace together with the metric name to distinguish them.
| Interface | Namespace in each result | Metric name |
|---|---|---|
| REST | ["example", "sales", "mart", "sales_model"] |
total_revenue |
Java / Python, using the loaded sales catalog |
["mart", "sales_model"] |
total_revenue |
The SDK methods accept a schema namespace, such as Namespace.of("mart"). Do not include the
metalake, catalog, or model in that argument.
Retrieve Metric Definitions
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
'http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/mart/semantic-model-metrics?details=true'
For the same model, the response is:
{
"code": 0,
"metrics": [
{
"namespace": ["example", "sales", "mart", "sales_model"],
"metric": {
"name": "total_revenue",
"expression": {
"dialects": [
{"dialect": "ANSI_SQL", "expression": "SUM(orders.order_amount)"}
]
},
"datatype": "Decimal"
}
}
]
}
SemanticModelMetric[] metricInfos = models.listMetricInfos(Namespace.of("mart"));
metric_infos = models.list_metric_infos(Namespace.of("mart"))
Each SDK result exposes namespace() and metric(). The metric contains its name, expression,
and any stored data type, description, AI context, or custom extensions. To construct its identifier,
use NameIdentifier.of(info.namespace(), info.metric().name()) in Java or
NameIdentifier.builder(info.namespace(), info.metric().name()) in Python.
Ordering, Visibility, and Updates
Both listing modes sort results by the containing model's identifier and then by case-sensitive
metric name. Models without metrics contribute no entries. If there are no visible metrics, REST
returns an empty identifiers or metrics array and the SDKs return an empty array or list.
With authorization enabled, discovery requires access to the parent catalog and schema. It
includes metrics only from models the caller can discover through USE_SEMANTIC_MODEL,
MODIFY_SEMANTIC_MODEL, or ownership, as described in
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 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.
An empty result is a successful discovery response. Missing schemas, denied parent access, and unsupported operations are reported as errors. Storage or decoding failures fail the request instead of returning partial results. See the REST API reference for response and error details.
Alter a Semantic Model
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 |
|---|---|
| Rename within the schema | {"@type":"rename","newName":"renamed_model"} |
| Update or clear the comment | {"@type":"updateComment","newComment":"Reviewed sales definitions"}; use null to clear it. |
| Set a property | {"@type":"setProperty","property":"domain","value":"finance"} |
| Remove a property | {"@type":"removeProperty","property":"domain"} |
| Replace the definition | Set @type to replaceDefinition and supply the complete native definition in definition. |
curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"updates": [
{"@type": "updateComment", "newComment": "Reviewed sales definitions"},
{"@type": "setProperty", "property": "domain", "value": "finance"}
]
}' http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/mart/semantic-models/sales_model
SemanticModel altered = models.alterSemanticModel(
ident,
SemanticModelChange.updateComment("Reviewed sales definitions"),
SemanticModelChange.setProperty("domain", "finance"));
altered = models.alter_semantic_model(
ident,
SemanticModelChange.update_comment("Reviewed sales definitions"),
SemanticModelChange.set_property("domain", "finance"))
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.
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));
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
An Ossie document uses snake_case names, string source identifiers, and root-level datasets, relationships, and metrics. See Exchanging Definitions for the mapping from the native REST format.
Import a Document
Save the following as sales.ossie.yaml. It uses a different model name so it can be imported
alongside the model created above:
version: 0.2.0.dev0
name: imported_sales_model
description: Imported sales definitions
datasets:
- name: orders
source: sales.mart.orders
primary_key: [order_id]
fields:
- name: order_amount
expression:
dialects:
- dialect: ANSI_SQL
expression: order_amount
datatype: Decimal
- name: order_id
expression:
dialects:
- dialect: ANSI_SQL
expression: order_id
- name: customer_id
expression:
dialects:
- dialect: ANSI_SQL
expression: customer_id
- name: customers
source: sales.mart.customers
primary_key: [customer_id]
unique_keys: [[customer_code]]
fields:
- name: customer_id
expression:
dialects:
- dialect: ANSI_SQL
expression: customer_id
- name: customer_code
expression:
dialects:
- dialect: ANSI_SQL
expression: customer_code
relationships:
- name: orders_to_customers
from: orders
to: customers
from_columns: [customer_id]
to_columns: [customer_id]
metrics:
- name: total_revenue
expression:
dialects:
- dialect: ANSI_SQL
expression: SUM(orders.order_amount)
datatype: Decimal
custom_extensions:
- vendor_name: GRAVITINO_PROPERTIES
data: '{"domain":"sales"}'
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/yaml" --data-binary @sales.ossie.yaml \
http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/mart/semantic-models/ossie
SemanticModel importedModel = models.importOssieDocument(
Namespace.of("mart"), OssieDocument.yaml(Files.readString(Path.of("sales.ossie.yaml"))));
imported_model = models.import_ossie_document(
Namespace.of("mart"), Path("sales.ossie.yaml").read_text(encoding="utf-8"))
Import creates a new model using the name in the document and applies the same validation as
native creation. An existing name reports a conflict. REST returns the native semanticModel
response; the SDKs return a SemanticModel.
Send the raw document text. For JSON, use Content-Type: application/json in REST,
OssieDocument.json(...) in Java, or document_format="json" in Python. YAML requests use
application/yaml; application/x-yaml and text/yaml are also accepted. An omitted content type
defaults to YAML, while an unsupported content type returns 415. Use an explicit content type
with curl, since its data options otherwise send a form content type.
Export a Document
Export the native model as an Ossie JSON document:
curl 'http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/mart/semantic-models/sales_model/ossie?format=json' \
-o exported-sales.ossie.json
OssieDocument exported = models.exportOssieDocument(ident, OssieFormat.JSON);
Files.writeString(Path.of("exported-sales.ossie.json"), exported.content());
exported = models.export_ossie_document(ident, document_format="json")
Path("exported-sales.ossie.json").write_text(exported, encoding="utf-8")
For YAML, use format=yaml in REST, OssieFormat.YAML in Java, or document_format="yaml" in
Python. REST and Python default to YAML when the format is omitted. REST returns the document
text without the native response wrapper, and Python returns that text unchanged.
The ossie-version model property supplies the document's version. Native creation records the
server's default when the property is omitted; import records the document version. Other model
properties are exchanged through the root GRAVITINO_PROPERTIES custom extension, whose data
is a JSON object encoded as a string. Its values must be strings. Use properties when creating a
model through the native API; the reserved extension is for Ossie exchange.
Ownership and Privileges
When authorization is enabled, a model's creator becomes its owner. For callers using explicit
privilege grants, access also requires USE_CATALOG and USE_SCHEMA on the parent objects:
| Operation | Required model privilege or ownership |
|---|---|
| Create or import | CREATE_SEMANTIC_MODEL on the containing schema or an ancestor. |
| Discover, load, or export | USE_SEMANTIC_MODEL, MODIFY_SEMANTIC_MODEL, or ownership. |
| Alter or rename | MODIFY_SEMANTIC_MODEL or ownership. |
| Drop | Ownership; MODIFY_SEMANTIC_MODEL alone is insufficient. |
Parent owners can also operate on contained models under the access-control rules. A schema owner still needs access to the catalog. Create, import, and definition replacement additionally check the caller's access to every source table or view. Permission to load a Semantic Model does not itself grant permission to read its source data.
Ownership and role grants use metadata object type SEMANTIC_MODEL and a name such as
sales.mart.sales_model within the selected metalake. See
Ownership and the
access-control walkthrough to manage owners and roles.
Setting a string property named owner does not transfer ownership.
Tags and Policies
Create a tag in the metalake before attaching it to a Semantic Model. For an existing tag named
certified, use the semantic_model object type in the REST path:
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{"tagsToAdd": ["certified"]}' \
http://localhost:8090/api/metalakes/example/objects/semantic_model/sales.mart.sales_model/tags
Tag operations have their own authorization requirements. See Manage Tags for creating, attaching, listing, and removing tags. Policies are selected through tags; see Policy-to-Tag Associations.
Drop a Semantic Model
Drop the models after trying the examples. Dropping removes the semantic metadata and its governance associations without deleting source tables, views, or data.
curl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/mart/semantic-models/sales_model
curl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/mart/semantic-models/imported_sales_model
boolean dropped = models.dropSemanticModel(ident);
boolean importedDropped = models.dropSemanticModel(
NameIdentifier.of("mart", "imported_sales_model"));
dropped = models.drop_semantic_model(ident)
imported_dropped = models.drop_semantic_model(
NameIdentifier.of("mart", "imported_sales_model"))
REST returns {"code":0,"dropped":true} when the model is dropped, while the SDKs return a boolean.
An authorized request for an absent model returns false (dropped: false in REST).
Other Interfaces
The Gravitino MCP server provides
list_of_semantic_models, load_semantic_model, create_semantic_model, alter_semantic_model,
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.