Skip to content

kelp.models.metric_view

Reference for the metric_view configuration model.

kelp.models.metric_view.MetricView pydantic-model

Bases: BaseModel

Metric View definition for Databricks.

The dimensions key (the spec synonym for fields) is canonicalized to fields on construction, so local YAML and remote-fetched state always compare and render consistently — Unity Catalog currently returns stored definitions with dimensions even when created with fields.

Attributes:

Name Type Description
name str

The name of the metric view.

catalog str | None

The catalog where the metric view will be created.

schema_ str | None

The schema where the metric view will be created.

definition dict[str, Any]

The metric view specification as a dictionary, following the Databricks metric view YAML reference (version, source, comment, filter, joins, fields, measures, …).

tags dict[str, str]

Optional tags for the metric view.

origin_file_path SkipJsonSchema[str] | None

Path to the source YAML file (internal use).

raw_config SkipJsonSchema[dict]

Preserve original, unparsed config (including placeholder vars).

Show JSON schema:
{
  "$defs": {
    "Grant": {
      "description": "Direct privileges assigned to a Unity Catalog principal.",
      "properties": {
        "principal": {
          "description": "User, service principal, or group",
          "title": "Principal",
          "type": "string"
        },
        "privileges": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "Unity Catalog privileges; an empty or null list marks a revoke",
          "title": "Privileges"
        }
      },
      "required": [
        "principal",
        "privileges"
      ],
      "title": "Grant",
      "type": "object"
    }
  },
  "description": "Metric View definition for Databricks.\n\nThe ``dimensions`` key (the spec synonym for ``fields``) is canonicalized\nto ``fields`` on construction, so local YAML and remote-fetched state\nalways compare and render consistently \u2014 Unity Catalog currently returns\nstored definitions with ``dimensions`` even when created with ``fields``.\n\nAttributes:\n    name: The name of the metric view.\n    catalog: The catalog where the metric view will be created.\n    schema_: The schema where the metric view will be created.\n    definition: The metric view specification as a dictionary, following\n                the Databricks metric view YAML reference (``version``,\n                ``source``, ``comment``, ``filter``, ``joins``,\n                ``fields``, ``measures``, \u2026).\n    tags: Optional tags for the metric view.\n    origin_file_path: Path to the source YAML file (internal use).\n    raw_config: Preserve original, unparsed config (including placeholder vars).",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "catalog": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Catalog"
    },
    "schema": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Schema"
    },
    "definition": {
      "additionalProperties": true,
      "description": "The metric view specification following the Databricks metric view YAML reference, passed through to DDL verbatim (plus optional Kelp-managed 'tags' on field/measure entries)",
      "title": "Definition",
      "type": "object"
    },
    "tags": {
      "additionalProperties": {
        "type": "string"
      },
      "title": "Tags",
      "type": "object"
    },
    "grants": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/Grant"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Direct Unity Catalog grants for the metric view",
      "title": "Grants"
    },
    "meta": {
      "additionalProperties": true,
      "description": "Generic user-defined metadata for filtering and grouping",
      "title": "Meta",
      "type": "object"
    }
  },
  "required": [
    "name"
  ],
  "title": "MetricView",
  "type": "object"
}

Config:

  • validate_by_name: True
  • validate_by_alias: True
  • serialize_by_alias: True

Fields:

Validators:

origin_file_path pydantic-field

origin_file_path = None

name pydantic-field

name

catalog pydantic-field

catalog = None

schema_ pydantic-field

schema_ = None

definition pydantic-field

definition

The metric view specification following the Databricks metric view YAML reference, passed through to DDL verbatim (plus optional Kelp-managed 'tags' on field/measure entries)

tags pydantic-field

tags

grants pydantic-field

grants = None

Direct Unity Catalog grants for the metric view

meta pydantic-field

meta

Generic user-defined metadata for filtering and grouping

raw_config pydantic-field

raw_config

model_config class-attribute instance-attribute

model_config = ConfigDict(validate_by_name=True, validate_by_alias=True, serialize_by_alias=True)

get_qualified_name

get_qualified_name()

Get the fully qualified metric view name including catalog/schema if applicable.

Source code in src/kelp/models/metric_view.py
def get_qualified_name(self) -> str:
    """Get the fully qualified metric view name including catalog/schema if applicable."""
    parts = []
    if self.catalog:
        parts.append(self.catalog)
    if self.schema_:
        parts.append(self.schema_)
    parts.append(self.name)
    return ".".join(parts)