Skip to content

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

70.8 KB
Raw Blame
# 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.

---

paths:

  /metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectFullName}/semantic-model-datasets:
    parameters:
      - $ref: "./openapi.yaml#/components/parameters/metalake"
      - name: metadataObjectType
        in: path
        required: true
        description: The source metadata object type
        schema:
          type: string
          enum: [table, view]
      - $ref: "./openapi.yaml#/components/parameters/metadataObjectFullName"
    get:
      tags:
        - semantic-model
      summary: List Semantic Model datasets associated with a source
      description: >-
        Lists datasets directly associated with a registered table or View in the same metalake,
        including models in other catalogs and schemas. Requires access to the source metadata
        and returns datasets only from models the caller can load, including access to each model's
        catalog and schema. Authorization evaluation failures exclude the affected models.
        Returns one identifier per matching dataset, with namespace
        [metalake, catalog, schema, semanticModel] and the exact, case-sensitive dataset name.
        Results are sorted by those components in order using UTF-16 code units, independently of
        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 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
        components cannot be represented reliably by this route.
      operationId: listSemanticModelDatasets
      responses:
        "200":
          $ref: "#/components/responses/SemanticModelDatasetListResponse"
        "400":
          $ref: "#/components/responses/SemanticModelBadRequestResponse"
        "403":
          $ref: "#/components/responses/SemanticModelForbiddenResponse"
        "404":
          description: The source or one of its parents does not exist
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
        "5XX":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

  /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/semantic-model-metrics:
    parameters:
      - $ref: "./openapi.yaml#/components/parameters/metalake"
      - $ref: "./openapi.yaml#/components/parameters/catalog"
      - $ref: "./openapi.yaml#/components/parameters/schema"
    get:
      tags:
        - semantic-model
      summary: List metrics across Semantic Models
      description: >-
        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
        access and include only metrics whose containing model is visible under the existing
        Semantic Model listing rules. Results are sorted by structured model identifier and then
        case-sensitive metric name. Models without metrics contribute no entries. Empty results
        contain an empty identifiers or metrics array. Storage or metric decoding failures fail
        the entire request, including decoding failures in models that would be filtered out.
      operationId: listSemanticModelMetrics
      parameters:
        - name: details
          in: query
          required: false
          description: Whether to return complete metric definitions instead of identifiers
          schema:
            type: boolean
            default: false
      responses:
        "200":
          $ref: "#/components/responses/SemanticModelMetricListResponse"
        "400":
          $ref: "#/components/responses/SemanticModelBadRequestResponse"
        "403":
          $ref: "#/components/responses/SemanticModelForbiddenResponse"
        "404":
          $ref: "#/components/responses/SemanticModelParentNotFoundResponse"
        "501":
          $ref: "#/components/responses/SemanticModelUnsupportedCatalogResponse"
        "5XX":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

  /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/semantic-models:
    parameters:
      - $ref: "./openapi.yaml#/components/parameters/metalake"
      - $ref: "./openapi.yaml#/components/parameters/catalog"
      - $ref: "./openapi.yaml#/components/parameters/schema"

    get:
      tags:
        - semantic-model
      summary: List Semantic Models
      description: >-
        Lists the Semantic Models in a schema. Semantic Models are supported only for relational
        catalogs. Each returned identifier uses the full metalake.catalog.schema.name namespace.
      operationId: listSemanticModels
      responses:
        "200":
          $ref: "#/components/responses/SemanticModelListResponse"
        "400":
          $ref: "#/components/responses/SemanticModelBadRequestResponse"
        "403":
          $ref: "#/components/responses/SemanticModelForbiddenResponse"
        "404":
          $ref: "#/components/responses/SemanticModelParentNotFoundResponse"
        "501":
          $ref: "#/components/responses/SemanticModelUnsupportedCatalogResponse"
        "5XX":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

    post:
      tags:
        - semantic-model
      summary: Create a Semantic Model
      description: >-
        Creates a schema-scoped Semantic Model in a relational catalog. The complete definition is
        validated before the model is stored, including source identifier shape, 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.
      operationId: createSemanticModel
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SemanticModelCreateRequest"
            examples:
              SemanticModelCreateRequest:
                $ref: "#/components/examples/SemanticModelCreateRequest"
      responses:
        "200":
          $ref: "#/components/responses/SemanticModelResponse"
        "400":
          $ref: "#/components/responses/SemanticModelBadRequestResponse"
        "403":
          $ref: "#/components/responses/SemanticModelForbiddenResponse"
        "404":
          $ref: "#/components/responses/SemanticModelParentNotFoundResponse"
        "409":
          $ref: "#/components/responses/SemanticModelAlreadyExistsResponse"
        "501":
          $ref: "#/components/responses/SemanticModelUnsupportedCatalogResponse"
        "502":
          $ref: "#/components/responses/SemanticModelConnectionFailedResponse"
        "5XX":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

  /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/semantic-models/ossie:
    parameters:
      - $ref: "./openapi.yaml#/components/parameters/metalake"
      - $ref: "./openapi.yaml#/components/parameters/catalog"
      - $ref: "./openapi.yaml#/components/parameters/schema"

    post:
      tags:
        - semantic-model
      summary: Import an Apache Ossie Semantic Model
      description: >-
        Imports one standalone Apache Ossie document and creates the represented Semantic Model.
        The imported definition is validated before the model is stored, including source identifier
        shape, 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.
        The request body is the raw JSON or YAML document, not a JSON-encoded string. Content-Type
        selects the parser; when the header is absent, the body is parsed as YAML. Parsing does not
        fall back to another format.
      operationId: importOssieDocument
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OssieSemanticModelDocument"
            examples:
              OssieSemanticModelDocument:
                $ref: "#/components/examples/OssieSemanticModelDocument"
          application/yaml:
            schema:
              $ref: "#/components/schemas/OssieSemanticModelDocument"
            examples:
              OssieSemanticModelDocument:
                $ref: "#/components/examples/OssieSemanticModelDocument"
          application/x-yaml:
            schema:
              $ref: "#/components/schemas/OssieSemanticModelDocument"
            examples:
              OssieSemanticModelDocument:
                $ref: "#/components/examples/OssieSemanticModelDocument"
          text/yaml:
            schema:
              $ref: "#/components/schemas/OssieSemanticModelDocument"
            examples:
              OssieSemanticModelDocument:
                $ref: "#/components/examples/OssieSemanticModelDocument"
      responses:
        "200":
          $ref: "#/components/responses/SemanticModelResponse"
        "400":
          $ref: "#/components/responses/SemanticModelBadRequestResponse"
        "403":
          $ref: "#/components/responses/SemanticModelForbiddenResponse"
        "404":
          $ref: "#/components/responses/SemanticModelParentNotFoundResponse"
        "409":
          $ref: "#/components/responses/SemanticModelAlreadyExistsResponse"
        "415":
          description: >-
            Unsupported Media Type - An explicitly supplied Content-Type is not one of
            application/json, application/yaml, application/x-yaml, or text/yaml
        "501":
          $ref: "#/components/responses/SemanticModelUnsupportedCatalogResponse"
        "502":
          $ref: "#/components/responses/SemanticModelConnectionFailedResponse"
        "5XX":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

  /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/semantic-models/{semanticModel}:
    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: Load a Semantic Model
      description: Returns the active revision with its nested definition, publication metadata, and audit data.
      operationId: loadSemanticModel
      responses:
        "200":
          $ref: "#/components/responses/SemanticModelResponse"
        "400":
          $ref: "#/components/responses/SemanticModelBadRequestResponse"
        "403":
          $ref: "#/components/responses/SemanticModelForbiddenResponse"
        "404":
          $ref: "#/components/responses/SemanticModelNotFoundResponse"
        "501":
          $ref: "#/components/responses/SemanticModelUnsupportedCatalogResponse"
        "5XX":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

    put:
      tags:
        - semantic-model
      summary: Alter a Semantic Model
      description: >-
        Applies the ordered updates atomically. The server validates and converts the complete
        update batch before dispatch; if any update or the resulting model is invalid, none of the
        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. 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
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SemanticModelUpdatesRequest"
            examples:
              SemanticModelUpdatesRequest:
                $ref: "#/components/examples/SemanticModelUpdatesRequest"
      responses:
        "200":
          $ref: "#/components/responses/SemanticModelResponse"
        "400":
          $ref: "#/components/responses/SemanticModelBadRequestResponse"
        "403":
          $ref: "#/components/responses/SemanticModelForbiddenResponse"
        "404":
          $ref: "#/components/responses/SemanticModelNotFoundResponse"
        "409":
          $ref: "#/components/responses/SemanticModelAlterConflictResponse"
        "501":
          $ref: "#/components/responses/SemanticModelUnsupportedCatalogResponse"
        "502":
          $ref: "#/components/responses/SemanticModelConnectionFailedResponse"
        "5XX":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

    delete:
      tags:
        - semantic-model
      summary: Drop a Semantic Model
      description: >-
        Drops the specified Semantic Model. A missing schema or Semantic Model is reported as a
        successful response with dropped set to false.
      operationId: dropSemanticModel
      responses:
        "200":
          $ref: "./openapi.yaml#/components/responses/DropResponse"
        "400":
          $ref: "#/components/responses/SemanticModelBadRequestResponse"
        "403":
          $ref: "#/components/responses/SemanticModelForbiddenResponse"
        "404":
          description: Not Found - The target metalake or catalog does not exist
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                NoSuchMetalakeException:
                  $ref: "./metalakes.yaml#/components/examples/NoSuchMetalakeException"
                NoSuchCatalogException:
                  $ref: "./catalogs.yaml#/components/examples/NoSuchCatalogException"
        "409":
          $ref: "#/components/responses/SemanticModelOptimisticLockResponse"
        "501":
          $ref: "#/components/responses/SemanticModelUnsupportedCatalogResponse"
        "5XX":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

  /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/semantic-models/{semanticModel}/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"

    get:
      tags:
        - semantic-model
      summary: Export a Semantic Model as an Apache Ossie document
      description: >-
        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.
      operationId: exportOssieDocument
      parameters:
        - name: format
          in: query
          description: The serialized document format
          required: false
          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/SemanticModelNotFoundResponse"
        "501":
          $ref: "#/components/responses/SemanticModelUnsupportedCatalogResponse"
        "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:
      type: object
      description: The namespace and complete definition of a discovered metric
      required:
        - namespace
        - metric
      properties:
        namespace:
          type: array
          description: Full namespace [metalake, catalog, schema, semanticModel]
          minItems: 4
          maxItems: 4
          items:
            type: string
            minLength: 1
        metric:
          $ref: "#/components/schemas/Metric"
      additionalProperties: false

    MetricIdentifierListResponse:
      type: object
      description: Metric identifiers returned when details is false
      required:
        - code
        - identifiers
      properties:
        code:
          type: integer
          format: int32
          enum: [0]
        identifiers:
          type: array
          description: Identifiers with namespace [metalake, catalog, schema, semanticModel]
          items:
            $ref: "./openapi.yaml#/components/schemas/NameIdentifier"
      additionalProperties: false

    MetricInfoListResponse:
      type: object
      description: Complete metrics returned when details is true
      required:
        - code
        - metrics
      properties:
        code:
          type: integer
          format: int32
          enum: [0]
        metrics:
          type: array
          items:
            $ref: "#/components/schemas/SemanticModelMetric"
      additionalProperties: false

    AIContext:
      description: Additional context for AI tools, encoded as exactly one string or object value
      oneOf:
        - type: string
        - $ref: "#/components/schemas/AIContextObject"

    AIContextObject:
      type: object
      description: >-
        Structured context for AI tools. Unknown properties may contain any JSON value and are
        retained losslessly in input order.
      properties:
        instructions:
          type: string
          description: Instructions for AI tools on how to use the entity
        synonyms:
          type: array
          description: >-
            Alternative names and terms. Omitting the property differs from supplying an empty
            array.
          items:
            type: string
        examples:
          type: array
          description: >-
            Sample questions or use cases. Omitting the property differs from supplying an empty
            array.
          items:
            type: string
      additionalProperties: true

    SemanticModelSource:
      type: object
      description: >-
        A governed Table or logical View expressed as catalog.schema.name. The endpoint metalake is
        inherited and therefore is not included in this identifier.
      required:
        - namespace
        - name
      properties:
        namespace:
          type: array
          minItems: 2
          maxItems: 2
          description: Exactly the catalog and schema containing the source, in that order
          items:
            type: string
            minLength: 1
        name:
          type: string
          minLength: 1
          description: The source Table or logical View name
      additionalProperties: false

    Dataset:
      type: object
      description: A logical dataset backed by a governed Gravitino Table or logical View
      required:
        - name
        - source
      properties:
        name:
          type: string
          minLength: 1
          description: The dataset name, unique within the Semantic Model
        source:
          $ref: "#/components/schemas/SemanticModelSource"
        primaryKey:
          type: array
          description: >-
            Names of fields declared in this dataset's fields that form the primary key. The
            property may be omitted; an explicitly supplied empty array is retained as empty.
          items:
            type: string
            minLength: 1
        uniqueKeys:
          type: array
          description: >-
            Sets of field names declared in this dataset's fields that form unique keys. The
            property may be omitted; an explicitly supplied empty array is retained as empty.
          items:
            type: array
            minItems: 1
            items:
              type: string
              minLength: 1
        description:
          type: string
          description: The human-readable dataset description
        aiContext:
          $ref: "#/components/schemas/AIContext"
        fields:
          type: array
          description: >-
            Ordered fields in the dataset. The property may be omitted; an explicitly supplied
            empty array is retained as empty.
          items:
            $ref: "#/components/schemas/Field"
        customExtensions:
          type: array
          description: >-
            Vendor-specific extensions. The property may be omitted; an explicitly supplied empty
            array is retained as empty.
          items:
            $ref: "#/components/schemas/CustomExtension"
      additionalProperties: false

    OssieDataset:
      type: object
      description: >-
        An Apache Ossie dataset backed by a governed Gravitino Table or logical View
      required:
        - name
        - source
      properties:
        name:
          type: string
          minLength: 1
          description: The dataset name, unique within the Semantic Model
        source:
          type: string
          minLength: 1
          description: >-
            A catalog.schema.name source identifier. Segments containing dots or backticks use
            backtick quoting, and a backtick inside a quoted segment is doubled. Query sources are
            not supported.
        primary_key:
          type: array
          description: >-
            Names of fields declared in this dataset's fields that form the primary key. The
            property may be omitted; an explicitly supplied empty array is retained as empty.
          items:
            type: string
            minLength: 1
        unique_keys:
          type: array
          description: >-
            Sets of field names declared in this dataset's fields that form unique keys. The
            property may be omitted; an explicitly supplied empty array is retained as empty.
          items:
            type: array
            minItems: 1
            items:
              type: string
              minLength: 1
        description:
          type: string
          description: The human-readable dataset description
        ai_context:
          $ref: "#/components/schemas/AIContext"
        fields:
          type: array
          description: >-
            Ordered fields in the dataset. The property may be omitted; an explicitly supplied
            empty array is retained as empty.
          items:
            $ref: "#/components/schemas/OssieField"
        custom_extensions:
          type: array
          description: >-
            Vendor-specific extensions. The property may be omitted; an explicitly supplied empty
            array is retained as empty.
          items:
            $ref: "#/components/schemas/OssieCustomExtension"
      additionalProperties: false

    Field:
      type: object
      description: A row-level semantic attribute in a dataset
      required:
        - name
        - expression
      properties:
        name:
          type: string
          minLength: 1
          description: The field name, unique within its dataset
        expression:
          $ref: "#/components/schemas/Expression"
        dimension:
          $ref: "#/components/schemas/Dimension"
        label:
          type: string
          description: The display label used to categorize the field
        description:
          type: string
          description: The human-readable field description
        datatype:
          $ref: "#/components/schemas/SemanticModelDataType"
        aiContext:
          $ref: "#/components/schemas/AIContext"
        customExtensions:
          type: array
          description: >-
            Vendor-specific extensions. The property may be omitted; an explicitly supplied empty
            array is retained as empty.
          items:
            $ref: "#/components/schemas/CustomExtension"
      additionalProperties: false

    Relationship:
      type: object
      description: A relationship between two datasets in the same Semantic Model
      required:
        - name
        - from
        - to
        - fromColumns
        - toColumns
      properties:
        name:
          type: string
          minLength: 1
          description: The relationship name, unique within the Semantic Model
        from:
          type: string
          minLength: 1
          description: The source dataset name
        to:
          type: string
          minLength: 1
          description: The target dataset name
        fromColumns:
          type: array
          minItems: 1
          description: >-
            Non-empty field names declared by the from dataset. The array must have the same
            number of entries as toColumns.
          items:
            type: string
            minLength: 1
        toColumns:
          type: array
          minItems: 1
          description: >-
            Non-empty field names declared by the to dataset. The array must have the same number
            of entries as fromColumns.
          items:
            type: string
            minLength: 1
        aiContext:
          $ref: "#/components/schemas/AIContext"
        customExtensions:
          type: array
          description: >-
            Vendor-specific extensions. The property may be omitted; an explicitly supplied empty
            array is retained as empty.
          items:
            $ref: "#/components/schemas/CustomExtension"
      additionalProperties: false

    Metric:
      type: object
      description: A model-scoped quantitative measure
      required:
        - name
        - expression
      properties:
        name:
          type: string
          minLength: 1
          description: The metric name, unique within the Semantic Model
        expression:
          $ref: "#/components/schemas/Expression"
        description:
          type: string
          description: The human-readable metric description
        datatype:
          $ref: "#/components/schemas/SemanticModelDataType"
        aiContext:
          $ref: "#/components/schemas/AIContext"
        customExtensions:
          type: array
          description: >-
            Vendor-specific extensions. The property may be omitted; an explicitly supplied empty
            array is retained as empty.
          items:
            $ref: "#/components/schemas/CustomExtension"
      additionalProperties: false

    Expression:
      type: object
      description: An expression with one or more ordered dialect-specific representations
      required:
        - dialects
      properties:
        dialects:
          type: array
          minItems: 1
          description: Each dialect identifier may occur at most once
          items:
            $ref: "#/components/schemas/DialectExpression"
      additionalProperties: false

    DialectExpression:
      type: object
      description: An expression written in a specific dialect
      required:
        - dialect
        - expression
      properties:
        dialect:
          type: string
          minLength: 1
          description: >-
            An open dialect identifier. ANSI_SQL, SNOWFLAKE, MDX, TABLEAU, DATABRICKS, MAQL, and
            BIGQUERY are well-known Apache Ossie values; other non-empty identifiers are accepted
            and preserved without conversion or fallback.
        expression:
          type: string
          minLength: 1
          description: The non-empty dialect-specific expression text
      additionalProperties: false

    Dimension:
      type: object
      description: >-
        Dimension metadata for a field. An empty object is valid and remains distinct from an
        omitted dimension.
      properties:
        isTime:
          type: boolean
          nullable: true
          description: Whether consumers should treat the field as a time dimension
      additionalProperties: false

    CustomExtension:
      type: object
      description: Vendor-specific attributes retained for Semantic Model interchange
      required:
        - vendorName
        - data
      properties:
        vendorName:
          type: string
          description: The extension vendor name
        data:
          type: string
          description: Opaque vendor-specific data retained as a string
      additionalProperties: false

    OssieField:
      type: object
      description: A row-level semantic attribute in a dataset
      required:
        - name
        - expression
      properties:
        name:
          type: string
          minLength: 1
          description: The field name, unique within its dataset
        expression:
          $ref: "#/components/schemas/Expression"
        dimension:
          $ref: "#/components/schemas/OssieDimension"
        label:
          type: string
          description: The display label used to categorize the field
        description:
          type: string
          description: The human-readable field description
        datatype:
          $ref: "#/components/schemas/SemanticModelDataType"
        ai_context:
          $ref: "#/components/schemas/AIContext"
        custom_extensions:
          type: array
          description: >-
            Vendor-specific extensions. The property may be omitted; an explicitly supplied empty
            array is retained as empty.
          items:
            $ref: "#/components/schemas/OssieCustomExtension"
      additionalProperties: false

    OssieRelationship:
      type: object
      description: A relationship between two datasets in the same Semantic Model
      required:
        - name
        - from
        - to
        - from_columns
        - to_columns
      properties:
        name:
          type: string
          minLength: 1
          description: The relationship name, unique within the Semantic Model
        from:
          type: string
          minLength: 1
          description: The source dataset name
        to:
          type: string
          minLength: 1
          description: The target dataset name
        from_columns:
          type: array
          minItems: 1
          description: >-
            Non-empty field names declared by the from dataset. The array must have the same
            number of entries as to_columns.
          items:
            type: string
            minLength: 1
        to_columns:
          type: array
          minItems: 1
          description: >-
            Non-empty field names declared by the to dataset. The array must have the same number
            of entries as from_columns.
          items:
            type: string
            minLength: 1
        ai_context:
          $ref: "#/components/schemas/AIContext"
        custom_extensions:
          type: array
          description: >-
            Vendor-specific extensions. The property may be omitted; an explicitly supplied empty
            array is retained as empty.
          items:
            $ref: "#/components/schemas/OssieCustomExtension"
      additionalProperties: false

    OssieMetric:
      type: object
      description: A model-scoped quantitative measure
      required:
        - name
        - expression
      properties:
        name:
          type: string
          minLength: 1
          description: The metric name, unique within the Semantic Model
        expression:
          $ref: "#/components/schemas/Expression"
        description:
          type: string
          description: The human-readable metric description
        datatype:
          $ref: "#/components/schemas/SemanticModelDataType"
        ai_context:
          $ref: "#/components/schemas/AIContext"
        custom_extensions:
          type: array
          description: >-
            Vendor-specific extensions. The property may be omitted; an explicitly supplied empty
            array is retained as empty.
          items:
            $ref: "#/components/schemas/OssieCustomExtension"
      additionalProperties: false

    OssieDimension:
      type: object
      description: >-
        Dimension metadata for a field. An empty object is valid and remains distinct from an
        omitted dimension.
      properties:
        is_time:
          type: boolean
          description: Whether consumers should treat the field as a time dimension
      additionalProperties: false

    OssieCustomExtension:
      type: object
      description: Vendor-specific attributes retained for Semantic Model interchange
      required:
        - vendor_name
        - data
      properties:
        vendor_name:
          type: string
          description: The extension vendor name
        data:
          type: string
          description: Opaque vendor-specific data retained as a string
      additionalProperties: false

    SemanticModelDataType:
      type: string
      description: The exact wire value for a logical field or metric data type
      enum:
        - String
        - Integer
        - Decimal
        - Float
        - Boolean
        - Date
        - Time
        - DateTime
        - DateTimeTz
        - Opaque

    SemanticModelDefinition:
      type: object
      description: The complete replaceable semantic definition, without entity metadata
      required:
        - datasets
      properties:
        aiContext:
          $ref: "#/components/schemas/AIContext"
        datasets:
          type: array
          minItems: 1
          description: The non-empty ordered datasets in the Semantic Model
          items:
            $ref: "#/components/schemas/Dataset"
        relationships:
          type: array
          description: >-
            Ordered relationships. The property may be omitted; an explicitly supplied empty array
            is retained as empty.
          items:
            $ref: "#/components/schemas/Relationship"
        metrics:
          type: array
          description: >-
            Ordered metrics. The property may be omitted; an explicitly supplied empty array is
            retained as empty.
          items:
            $ref: "#/components/schemas/Metric"
        customExtensions:
          type: array
          description: >-
            Vendor-specific extensions. The root vendorName GRAVITINO_PROPERTIES is reserved and
            cannot be supplied in a native definition. The property may be omitted; an explicitly
            supplied empty array is retained as empty.
          items:
            $ref: "#/components/schemas/CustomExtension"
      additionalProperties: false

    OssieSemanticModelDocument:
      type: object
      description: >-
        A standalone Apache Ossie document. Unlike the native Gravitino response, its semantic
        definition is at the document root and it contains no response envelope, audit data, or
        direct properties object.
      required:
        - version
        - name
        - datasets
      properties:
        version:
          type: string
          minLength: 1
          description: >-
            The non-blank Apache Ossie document version, stored in the ossie-version model property
            on import. Export uses that property or defaults to 0.2.0.dev0 when it is absent. The
            version is preserved without restricting it to a fixed allowlist.
        name:
          type: string
          minLength: 1
          description: The Semantic Model name
        description:
          type: string
          description: The human-readable Semantic Model description
        ai_context:
          $ref: "#/components/schemas/AIContext"
        datasets:
          type: array
          minItems: 1
          description: The non-empty ordered datasets in the Semantic Model
          items:
            $ref: "#/components/schemas/OssieDataset"
        relationships:
          type: array
          description: >-
            Ordered relationships. The property may be omitted; an explicitly supplied empty array
            is retained as empty.
          items:
            $ref: "#/components/schemas/OssieRelationship"
        metrics:
          type: array
          description: >-
            Ordered metrics. The property may be omitted; an explicitly supplied empty array is
            retained as empty.
          items:
            $ref: "#/components/schemas/OssieMetric"
        custom_extensions:
          type: array
          description: >-
            Vendor-specific extensions. At most one root GRAVITINO_PROPERTIES extension carries
            Gravitino-specific properties as a JSON object encoded in a string, with string values
            only. Import consumes this extension into model properties; an ossie-version value in
            its data must match the document version. Export omits ossie-version from the extension
            and writes it as version instead. Other extensions and nested GRAVITINO_PROPERTIES
            extensions remain opaque. The property may be omitted; an explicitly supplied empty
            array is normalized to an absent customExtensions in the native definition on import.
          items:
            $ref: "#/components/schemas/OssieCustomExtension"
      additionalProperties: false

    SemanticModel:
      type: object
      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
          description: The Semantic Model name
        comment:
          type: string
          nullable: true
          description: The comment; the property is omitted when no comment is set
        definition:
          $ref: "#/components/schemas/SemanticModelDefinition"
        properties:
          type: object
          description: Gravitino-specific Semantic Model properties, including the Ossie version
          additionalProperties:
            type: string
        audit:
          $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
      required:
        - name
        - definition
      properties:
        name:
          type: string
          minLength: 1
          description: The non-blank Semantic Model name
        comment:
          type: string
          nullable: true
          description: The optional Semantic Model comment
        definition:
          $ref: "#/components/schemas/SemanticModelDefinition"
        properties:
          type: object
          nullable: true
          description: >-
            Optional Gravitino-specific properties. Omitted or null properties use the defaults.
            The ossie-version property must be non-blank and defaults to 0.2.0.dev0.
          additionalProperties:
            type: string
      additionalProperties: false

    SemanticModelUpdatesRequest:
      type: object
      description: A non-empty ordered update batch applied atomically
      required:
        - updates
      properties:
        expectedRevision:
          type: integer
          format: int32
          minimum: 1
          description: The expected latest revision. Required for replaceDefinition.
        updates:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/SemanticModelUpdateRequest"
      additionalProperties: false

    SemanticModelUpdateRequest:
      description: One polymorphic Semantic Model update
      oneOf:
        - $ref: "#/components/schemas/RenameSemanticModelRequest"
        - $ref: "#/components/schemas/UpdateSemanticModelCommentRequest"
        - $ref: "#/components/schemas/SetSemanticModelPropertyRequest"
        - $ref: "#/components/schemas/RemoveSemanticModelPropertyRequest"
        - $ref: "#/components/schemas/ReplaceSemanticModelDefinitionRequest"
      discriminator:
        propertyName: "@type"
        mapping:
          rename: "#/components/schemas/RenameSemanticModelRequest"
          updateComment: "#/components/schemas/UpdateSemanticModelCommentRequest"
          setProperty: "#/components/schemas/SetSemanticModelPropertyRequest"
          removeProperty: "#/components/schemas/RemoveSemanticModelPropertyRequest"
          replaceDefinition: "#/components/schemas/ReplaceSemanticModelDefinitionRequest"

    RenameSemanticModelRequest:
      type: object
      description: Renames the Semantic Model
      required:
        - "@type"
        - newName
      properties:
        "@type":
          type: string
          enum:
            - rename
        newName:
          type: string
          minLength: 1
          description: The new non-blank Semantic Model name
      example: {
        "@type": "rename",
        "newName": "sales_model_v2"
      }

    UpdateSemanticModelCommentRequest:
      type: object
      description: >-
        Replaces the comment. An omitted or null newComment clears the comment; an explicit empty
        string is stored as an empty comment.
      required:
        - "@type"
      properties:
        "@type":
          type: string
          enum:
            - updateComment
        newComment:
          type: string
          nullable: true
          description: The new comment, null to clear it, or an empty string to retain empty
      example: {
        "@type": "updateComment",
        "newComment": "Updated sales definitions"
      }

    SetSemanticModelPropertyRequest:
      type: object
      description: Sets or replaces one Gravitino-specific property
      required:
        - "@type"
        - property
        - value
      properties:
        "@type":
          type: string
          enum:
            - setProperty
        property:
          type: string
          minLength: 1
          description: The non-blank property name
        value:
          type: string
          description: The property value; an empty string is valid
      example: {
        "@type": "setProperty",
        "property": "domain",
        "value": "sales"
      }

    RemoveSemanticModelPropertyRequest:
      type: object
      description: Removes one Gravitino-specific property if it exists
      required:
        - "@type"
        - property
      properties:
        "@type":
          type: string
          enum:
            - removeProperty
        property:
          type: string
          minLength: 1
          description: The non-blank property name
      example: {
        "@type": "removeProperty",
        "property": "legacy"
      }

    ReplaceSemanticModelDefinitionRequest:
      type: object
      description: Replaces and validates the complete nested definition atomically
      required:
        - "@type"
        - definition
      properties:
        "@type":
          type: string
          enum:
            - replaceDefinition
        definition:
          $ref: "#/components/schemas/SemanticModelDefinition"
      example: {
        "@type": "replaceDefinition",
        "definition": {
          "datasets": [
            {
              "name": "orders",
              "source": {
                "namespace": ["sales", "mart"],
                "name": "orders"
              },
              "fields": []
            }
          ],
          "relationships": [],
          "metrics": [],
          "customExtensions": []
        }
      }

  responses:
    SemanticModelDatasetListResponse:
      description: Fully qualified identifiers of visible datasets directly associated with the source
      content:
        application/vnd.gravitino.v1+json:
          schema:
            type: object
            required: [code, identifiers]
            properties:
              code:
                type: integer
                format: int32
                enum: [0]
              identifiers:
                type: array
                items:
                  type: object
                  required: [namespace, name]
                  properties:
                    namespace:
                      type: array
                      description: Full namespace [metalake, catalog, schema, semanticModel]
                      minItems: 4
                      maxItems: 4
                      items:
                        type: string
                        minLength: 1
                    name:
                      type: string
                      minLength: 1
                      description: The exact, case-sensitive dataset name, which may contain dots
                  additionalProperties: false
            additionalProperties: false
          examples:
            SharedSource:
              summary: Two datasets in one model referencing the same source
              value:
                code: 0
                identifiers:
                  - namespace: [example, analytics, semantic, employee_analysis]
                    name: employee
                  - namespace: [example, analytics, semantic, employee_analysis]
                    name: manager
            Empty:
              summary: The source exists but no matching datasets are visible
              value:
                code: 0
                identifiers: []

    SemanticModelMetricListResponse:
      description: Metric identifiers or complete metric definitions, according to details
      content:
        application/vnd.gravitino.v1+json:
          schema:
            oneOf:
              - $ref: "#/components/schemas/MetricIdentifierListResponse"
              - $ref: "#/components/schemas/MetricInfoListResponse"
          examples:
            Identifiers:
              summary: details=false
              value:
                code: 0
                identifiers:
                  - namespace: [lake, sales, mart, sales_model]
                    name: total_revenue
            Definitions:
              summary: details=true
              value:
                code: 0
                metrics:
                  - namespace: [lake, sales, mart, sales_model]
                    metric:
                      name: total_revenue
                      expression:
                        dialects:
                          - dialect: ANSI_SQL
                            expression: SUM(orders.amount)

    SemanticModelListResponse:
      description: Returns the Semantic Model identifiers in the schema
      content:
        application/vnd.gravitino.v1+json:
          schema:
            type: object
            required:
              - code
              - identifiers
            properties:
              code:
                type: integer
                format: int32
                description: Status code of the response
                enum:
                  - 0
              identifiers:
                type: array
                description: Full Semantic Model identifiers
                items:
                  $ref: "./openapi.yaml#/components/schemas/NameIdentifier"
            additionalProperties: false
          examples:
            SemanticModelListResponse:
              $ref: "#/components/examples/SemanticModelListResponse"

    SemanticModelResponse:
      description: Returns the Semantic Model object with its nested definition
      content:
        application/vnd.gravitino.v1+json:
          schema:
            type: object
            required:
              - code
              - semanticModel
            properties:
              code:
                type: integer
                format: int32
                description: Status code of the response
                enum:
                  - 0
              semanticModel:
                $ref: "#/components/schemas/SemanticModel"
            additionalProperties: false
          examples:
            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:
        Content-Disposition:
          description: >-
            Attachment filename derived from the Semantic Model name, with characters outside
            A-Za-z0-9._- replaced by underscores, ending in .ossie.yaml or .ossie.json
          schema:
            type: string
            example: attachment; filename="sales_model.ossie.yaml"
      content:
        application/yaml:
          schema:
            $ref: "#/components/schemas/OssieSemanticModelDocument"
          examples:
            OssieSemanticModelDocument:
              $ref: "#/components/examples/OssieSemanticModelDocument"
        application/json:
          schema:
            $ref: "#/components/schemas/OssieSemanticModelDocument"
          examples:
            OssieSemanticModelDocument:
              $ref: "#/components/examples/OssieSemanticModelDocument"

    SemanticModelBadRequestResponse:
      description: >-
        Bad Request - The request is malformed or a Semantic Model definition, source, or update is
        invalid
      content:
        application/vnd.gravitino.v1+json:
          schema:
            $ref: "./openapi.yaml#/components/schemas/ErrorModel"
          examples:
            IllegalSemanticModelException:
              $ref: "#/components/examples/IllegalSemanticModelException"

    SemanticModelForbiddenResponse:
      description: Forbidden - The caller cannot access the requested or referenced metadata
      content:
        application/vnd.gravitino.v1+json:
          schema:
            $ref: "./openapi.yaml#/components/schemas/ErrorModel"
          examples:
            ForbiddenException:
              $ref: "#/components/examples/ForbiddenException"

    SemanticModelParentNotFoundResponse:
      description: Not Found - The target metalake, catalog, or schema does not exist
      content:
        application/vnd.gravitino.v1+json:
          schema:
            $ref: "./openapi.yaml#/components/schemas/ErrorModel"
          examples:
            NoSuchMetalakeException:
              $ref: "./metalakes.yaml#/components/examples/NoSuchMetalakeException"
            NoSuchCatalogException:
              $ref: "./catalogs.yaml#/components/examples/NoSuchCatalogException"
            NoSuchSchemaException:
              $ref: "./schemas.yaml#/components/examples/NoSuchSchemaException"

    SemanticModelNotFoundResponse:
      description: Not Found - The parent or target Semantic Model does not exist
      content:
        application/vnd.gravitino.v1+json:
          schema:
            $ref: "./openapi.yaml#/components/schemas/ErrorModel"
          examples:
            NoSuchMetalakeException:
              $ref: "./metalakes.yaml#/components/examples/NoSuchMetalakeException"
            NoSuchCatalogException:
              $ref: "./catalogs.yaml#/components/examples/NoSuchCatalogException"
            NoSuchSchemaException:
              $ref: "./schemas.yaml#/components/examples/NoSuchSchemaException"
            NoSuchSemanticModelException:
              $ref: "#/components/examples/NoSuchSemanticModelException"

    SemanticModelUnsupportedCatalogResponse:
      description: Not Implemented - Semantic Models are supported only by relational catalogs
      content:
        application/vnd.gravitino.v1+json:
          schema:
            $ref: "./openapi.yaml#/components/schemas/ErrorModel"
          examples:
            UnsupportedOperationException:
              $ref: "#/components/examples/UnsupportedOperationException"

    SemanticModelAlreadyExistsResponse:
      description: Conflict - The target Semantic Model already exists
      content:
        application/vnd.gravitino.v1+json:
          schema:
            $ref: "./openapi.yaml#/components/schemas/ErrorModel"
          examples:
            SemanticModelAlreadyExistsException:
              $ref: "#/components/examples/SemanticModelAlreadyExistsException"

    SemanticModelAlterConflictResponse:
      description: >-
        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:
            $ref: "./openapi.yaml#/components/schemas/ErrorModel"
          examples:
            SemanticModelAlreadyExistsException:
              $ref: "#/components/examples/SemanticModelAlreadyExistsException"
            OptimisticLockException:
              $ref: "#/components/examples/OptimisticLockException"

    SemanticModelOptimisticLockResponse:
      description: Conflict - The internal transaction lost an optimistic-lock race
      content:
        application/vnd.gravitino.v1+json:
          schema:
            $ref: "./openapi.yaml#/components/schemas/ErrorModel"
          examples:
            OptimisticLockException:
              $ref: "#/components/examples/OptimisticLockException"

    SemanticModelConnectionFailedResponse:
      description: Bad Gateway - A referenced source catalog is temporarily unavailable
      content:
        application/vnd.gravitino.v1+json:
          schema:
            $ref: "./openapi.yaml#/components/schemas/ErrorModel"
          examples:
            ConnectionFailedException:
              $ref: "#/components/examples/ConnectionFailedException"

  examples:
    OssieSemanticModelDocument:
      value: {
        "version": "0.2.0.dev0",
        "name": "sales_model",
        "description": "Governed sales definitions",
        "ai_context": {
          "instructions": "Use certified sales metrics for revenue questions"
        },
        "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"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "relationships": [],
        "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\"}"
          }
        ]
      }

    SemanticModelListResponse:
      value: {
        "code": 0,
        "identifiers": [
          {
            "namespace": ["lake", "sales", "mart"],
            "name": "sales_model"
          }
        ]
      }

    SemanticModelCreateRequest:
      value: {
        "name": "sales_model",
        "comment": "Governed sales definitions",
        "definition": {
          "aiContext": {
            "instructions": "Use certified sales metrics for revenue questions",
            "synonyms": ["sales semantics"],
            "confidence": 0.95
          },
          "datasets": [
            {
              "name": "orders",
              "source": {
                "namespace": ["sales", "mart"],
                "name": "orders"
              },
              "primaryKey": ["order_id"],
              "uniqueKeys": [],
              "description": "Governed order facts",
              "aiContext": "Use completed orders for revenue",
              "fields": [
                {
                  "name": "order_time",
                  "expression": {
                    "dialects": [
                      {
                        "dialect": "ANSI_SQL",
                        "expression": "order_time"
                      }
                    ]
                  },
                  "dimension": {
                    "isTime": true
                  },
                  "label": "Order time",
                  "datatype": "DateTimeTz"
                },
                {
                  "name": "order_amount",
                  "expression": {
                    "dialects": [
                      {
                        "dialect": "TRINO",
                        "expression": "order_amount"
                      }
                    ]
                  },
                  "description": "Order amount before refunds",
                  "datatype": "Decimal",
                  "customExtensions": [
                    {
                      "vendorName": "example",
                      "data": "{\"semantic_type\":\"money\"}"
                    }
                  ]
                },
                {
                  "name": "order_id",
                  "expression": {
                    "dialects": [
                      {
                        "dialect": "ANSI_SQL",
                        "expression": "order_id"
                      }
                    ]
                  }
                },
                {
                  "name": "customer_id",
                  "expression": {
                    "dialects": [
                      {
                        "dialect": "ANSI_SQL",
                        "expression": "customer_id"
                      }
                    ]
                  }
                }
              ],
              "customExtensions": []
            },
            {
              "name": "customers",
              "source": {
                "namespace": ["sales", "mart"],
                "name": "customers"
              },
              "fields": [
                {
                  "name": "customer_id",
                  "expression": {
                    "dialects": [
                      {
                        "dialect": "ANSI_SQL",
                        "expression": "customer_id"
                      }
                    ]
                  }
                }
              ]
            }
          ],
          "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)"
                  }
                ]
              },
              "description": "Total revenue across all orders",
              "datatype": "Decimal",
              "aiContext": {
                "examples": ["What was revenue last month?"]
              }
            }
          ],
          "customExtensions": [
            {
              "vendorName": "example",
              "data": "{\"certified\":true}"
            }
          ]
        },
        "properties": {
          "domain": "sales"
        }
      }

    SemanticModelUpdatesRequest:
      value: {
        "expectedRevision": 1,
        "updates": [
          {
            "@type": "updateComment",
            "newComment": ""
          },
          {
            "@type": "setProperty",
            "property": "domain",
            "value": "commerce"
          },
          {
            "@type": "removeProperty",
            "property": "legacy"
          },
          {
            "@type": "replaceDefinition",
            "definition": {
              "datasets": [
                {
                  "name": "orders",
                  "source": {
                    "namespace": ["sales", "mart"],
                    "name": "orders"
                  },
                  "fields": []
                }
              ],
              "relationships": [],
              "metrics": [],
              "customExtensions": []
            }
          }
        ]
      }

    SemanticModelResponse:
      value: {
        "code": 0,
        "semanticModel": {
          "revision": 2,
          "status": "PUBLISHED",
          "publishedBy": "gravitino",
          "publishedAt": "2026-01-02T00:00:00Z",
          "name": "sales_model",
          "comment": "Governed sales definitions",
          "definition": {
            "aiContext": "Use certified sales definitions",
            "datasets": [
              {
                "name": "orders",
                "source": {
                  "namespace": ["sales", "mart"],
                  "name": "orders"
                },
                "fields": []
              }
            ],
            "relationships": [],
            "metrics": [],
            "customExtensions": []
          },
          "properties": {
            "domain": "sales"
          },
          "audit": {
            "creator": "gravitino",
            "createTime": "2026-01-01T00:00:00Z",
            "lastModifier": "gravitino",
            "lastModifiedTime": "2026-01-01T00:00:00Z"
          }
        }
      }

    IllegalSemanticModelException:
      value: {
        "code": 1001,
        "type": "IllegalSemanticModelException",
        "message": "datasets[0].source: source must use catalog.schema.name",
        "stack": [
          "org.apache.gravitino.exceptions.IllegalSemanticModelException: datasets[0].source: source must use catalog.schema.name",
          "..."
        ]
      }

    NoSuchSemanticModelException:
      value: {
        "code": 1003,
        "type": "NoSuchSemanticModelException",
        "message": "Semantic Model does not exist: sales_model",
        "stack": [
          "org.apache.gravitino.exceptions.NoSuchSemanticModelException: Semantic Model does not exist: sales_model",
          "..."
        ]
      }

    SemanticModelAlreadyExistsException:
      value: {
        "code": 1004,
        "type": "SemanticModelAlreadyExistsException",
        "message": "Semantic Model already exists: sales_model",
        "stack": [
          "org.apache.gravitino.exceptions.SemanticModelAlreadyExistsException: Semantic Model already exists: sales_model",
          "..."
        ]
      }

    UnsupportedOperationException:
      value: {
        "code": 1006,
        "type": "UnsupportedOperationException",
        "message": "The catalog does not support Semantic Model operations",
        "stack": [
          "java.lang.UnsupportedOperationException: The catalog does not support Semantic Model operations",
          "..."
        ]
      }

    ConnectionFailedException:
      value: {
        "code": 1007,
        "type": "ConnectionFailedException",
        "message": "A referenced source catalog is unavailable",
        "stack": [
          "org.apache.gravitino.exceptions.ConnectionFailedException: A referenced source catalog is unavailable",
          "..."
        ]
      }

    ForbiddenException:
      value: {
        "code": 1008,
        "type": "ForbiddenException",
        "message": "The caller cannot access referenced source metadata",
        "stack": [
          "org.apache.gravitino.exceptions.ForbiddenException: The caller cannot access referenced source metadata",
          "..."
        ]
      }

    OptimisticLockException:
      value: {
        "code": 1012,
        "type": "OptimisticLockException",
        "message": "The Semantic Model changed during the internal transaction",
        "stack": [
          "org.apache.gravitino.exceptions.OptimisticLockException: The Semantic Model changed during the internal transaction",
          "..."
        ]
      }