Skip to content

Schema

laktory.models.resources.databricks.Schema ¤

Bases: UnityCatalogMixin, TagsMixin, PoliciesMixin, AccessRequestDestinationsMixin, SchemaBase

A schema (also called a database) is the second layer of Unity Catalog's three-level namespace. A schema organizes tables and views.

Examples:

import io

from laktory import models

schema_yaml = '''
catalog_name: dev
name: engineering
tags:
  domain: engineering
grants:
- principal: domain-engineering
  privileges:
  - SELECT
policies:
- name: mask_pii
  policy_type: POLICY_TYPE_COLUMN_MASK
  for_securable_type: TABLE
  to_principals:
  - account users
  except_principals:
  - domain-engineering
  match_columns:
  - condition: hasTag('pii')
    alias: pii_col
  column_mask:
    function_name: dev.engineering.mask_string
    on_column: pii_col
'''
schema = models.resources.databricks.Schema.model_validate_yaml(
    io.StringIO(schema_yaml)
)
References
BASE DESCRIPTION
catalog_name

Name of the catalog storing the schema

TYPE: str | VariableType DEFAULT: None

comment

User-provided free-form text description.

TYPE: str | None | VariableType DEFAULT: None

enable_predictive_optimization

Whether predictive optimization should be enabled for this object and objects under it.

TYPE: str | None | VariableType DEFAULT: None

force_destroy

If True schema can be deleted, even when not empty

TYPE: bool | VariableType DEFAULT: True

metastore_id

Unique identifier of parent metastore.

TYPE: str | None | VariableType DEFAULT: None

name

Name of schema, relative to parent catalog.

TYPE: str | VariableType

owner

Username of current owner of schema.

TYPE: str | None | VariableType DEFAULT: None

properties

A map of key-value properties attached to the securable.

TYPE: dict[str, str] | None | VariableType DEFAULT: None

storage_root

Storage root URL for managed tables within schema.

TYPE: str | None | VariableType DEFAULT: None

LAKTORY DESCRIPTION
access_request_destinations

Destinations (email, Slack, Microsoft Teams, webhook or the securable owner) notified when users request access to this securable. Deployed as an AccessRequestDestinations resource.

TYPE: list[AccessRequestDestinationsDestinations] DEFAULT: None

grant

Non-destructive grant for specific principal(s). Adds or updates privileges for the listed principal(s) and leaves grants for all other principals untouched. Use when access is managed from multiple sources (Laktory, Databricks UI, etc.). Mutually exclusive with grants.

TYPE: SchemaGrant | list[SchemaGrant] | VariableType DEFAULT: None

grants

Authoritative grant list for all principals. Replaces every existing grant on this Schema - including those set outside Laktory - with only the entries listed here. Use only when Laktory owns all access management for this resource. Mutually exclusive with grant.

TYPE: list[SchemaGrant | VariableType] | VariableType DEFAULT: None

policies

Attribute-based access control (ABAC) policies defined on this securable. on_securable_type and on_securable_fullname are set automatically.

TYPE: list[PolicyInfo] DEFAULT: None

tables

List of tables stored in the schema

TYPE: list[Table | VariableType] | VariableType DEFAULT: []

tags

Tags assigned to the entity as {tag_key: tag_value}. Use a null value for a key-only tag. Each tag is deployed as a separate tag assignment resource.

TYPE: dict[str, str | None] DEFAULT: None

volumes

List of volumes stored in the schema

TYPE: list[Volume | VariableType] | VariableType DEFAULT: []

METHOD DESCRIPTION
get_tags_additional_resources

Tag assignment resources for entity (a name or a resource reference).

ATTRIBUTE DESCRIPTION
additional_core_resources
  • schema grants

TYPE: list

full_name

Full schema name {catalog_name}.{schema_name}

TYPE: str

parent_full_name

Parent namespace in the UC three-level hierarchy

TYPE: str | None

additional_core_resources property ¤

  • schema grants
  • schema tags
  • schema policies
  • schema access request destinations
  • tables
  • volumes

full_name property ¤

Full schema name {catalog_name}.{schema_name}

parent_full_name property ¤

Parent namespace in the UC three-level hierarchy

get_tags_additional_resources(entity_type, entity, tags=None) ¤

Tag assignment resources for entity (a name or a resource reference). Defaults to the tags of this resource.

Source code in laktory/models/resources/databricks/_tagsmixin.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def get_tags_additional_resources(
    self, entity_type: str, entity: str, tags: dict[str, str | None] | None = None
) -> list:
    """
    Tag assignment resources for `entity` (a name or a resource reference).
    Defaults to the `tags` of this resource.
    """
    if tags is None:
        tags = self.tags
    resources = []
    for key, value in (tags or {}).items():
        if entity_type in WORKSPACE_ENTITY_TYPES:
            r = WorkspaceEntityTagAssignment(
                entity_type=entity_type,
                entity_id=entity,
                tag_key=key,
                tag_value=value,
            )
        else:
            r = EntityTagAssignment(
                entity_type=entity_type,
                entity_name=entity,
                tag_key=key,
                tag_value=value,
            )
        resources += [r]
    return resources

laktory.models.resources.databricks.schema.SchemaLookup ¤

Bases: ResourceLookup

PARAMETER DESCRIPTION
name

Full name of the schema: catalog.schema

TYPE: str | VariableType