Skip to content

Table

laktory.models.resources.databricks.Table ¤

Bases: UnityCatalogMixin, TagsMixin, PoliciesMixin, AccessRequestDestinationsMixin, TableBase

A table resides in the third layer of Unity Catalog’s three-level namespace. It contains rows of data.

Examples:

import io

from laktory import models

table_yaml = '''
name: slv_stock_prices
catalog_name: dev
schema_name: finance
table_type: MANAGED
columns:
- name: symbol
  type: STRING
- name: trader_email
  type: STRING
  tags:
    pii: email
tags:
  data_classification: confidential
grants:
- principal: account users
  privileges:
  - SELECT
'''
table = models.resources.databricks.Table.model_validate_yaml(
    io.StringIO(table_yaml)
)
References
BASE DESCRIPTION
catalog_name

Name of parent catalog. Change forces the creation of a new resource

TYPE: str | VariableType | None DEFAULT: None

cluster_id

All table CRUD operations must be executed on a running cluster or SQL warehouse. If a cluster_id is specified, it will be used to execute SQL commands to manage this table. If empty, a cluster will be created automatically with the name terraform-sql-table. Conflicts with warehouse_id

TYPE: str | None | VariableType DEFAULT: None

cluster_keys

a subset of columns to liquid cluster the table by. For automatic clustering, set cluster_keys to ['AUTO']. To turn off clustering, set it to ['NONE']. Conflicts with partitions

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

column

Table columns

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

comment

User-supplied free-form text

TYPE: str | None | VariableType DEFAULT: None

data_source_format

External tables are supported in multiple data source formats. The string constants identifying these formats are DELTA, CSV, JSON, AVRO, PARQUET, ORC, and TEXT. Change forces the creation of a new resource. Not supported for MANAGED tables or VIEW

TYPE: str | None | VariableType DEFAULT: None

name

User-visible name of column

TYPE: str | VariableType

options

Map of user defined table options. Change forces creation of a new resource

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

owner

User name/group name/sp application_id of the table owner

TYPE: str | None | VariableType DEFAULT: None

partitions

a subset of columns to partition the table by. Change forces the creation of a new resource. Conflicts with cluster_keys

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

properties

A map of table properties

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

schema_name

Name of parent Schema relative to parent Catalog. Change forces the creation of a new resource

TYPE: str | VariableType | None DEFAULT: None

storage_credential_name

For EXTERNAL Tables only: the name of storage credential to use. Change forces the creation of a new resource

TYPE: str | None | VariableType DEFAULT: None

storage_location

URL of storage location for Table data (required for EXTERNAL Tables). If the URL contains special characters, such as space, &, etc., they should be percent-encoded (space -> %20, etc.). Not supported for VIEW or MANAGED table_type

TYPE: str | None | VariableType DEFAULT: None

table_type

Distinguishes a view vs. managed/external Table. MANAGED, EXTERNAL or VIEW. Change forces the creation of a new resource

TYPE: str | VariableType

view_definition

SQL text defining the view (for table_type == 'VIEW'). Not supported for MANAGED or EXTERNAL table_type

TYPE: str | None | VariableType DEFAULT: None

warehouse_id

All table CRUD operations must be executed on a running cluster or SQL warehouse. If a warehouse_id is specified, that SQL warehouse will be used to execute SQL commands to manage this table. Conflicts with cluster_id

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: TableGrant | list[TableGrant] | VariableType DEFAULT: None

grants

Authoritative grant list for all principals. Replaces every existing grant on this Table - 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[TableGrant | 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

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

METHOD DESCRIPTION
get_tags_additional_resources

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

ATTRIBUTE DESCRIPTION
additional_core_resources
  • table grants

TYPE: list

column_names

List of column names

TYPE: list[str]

full_name

Table full name {catalog_name}.{schema_name}.{table_name}

TYPE: str

is_from_cdc

If True CDC source is used to build the table

TYPE: bool

parent_full_name

Parent namespace in the UC three-level hierarchy

TYPE: str | None

additional_core_resources property ¤

  • table grants
  • table and columns tags
  • table policies
  • table access request destinations

column_names property ¤

List of column names

full_name property ¤

Table full name {catalog_name}.{schema_name}.{table_name}

is_from_cdc property ¤

If True CDC source is used to build the table

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.table.TableColumn ¤

Bases: TableColumn

PARAMETER DESCRIPTION
comment

User-supplied free-form text

TYPE: str | None | VariableType DEFAULT: None

identity

Whether the field is an identity column. Can be default, always, or unset. It is unset by default

TYPE: str | None | VariableType DEFAULT: None

name

User-visible name of column

TYPE: str | VariableType

nullable

Whether field is nullable (Default: true)

TYPE: bool | None | VariableType DEFAULT: None

tags

Tags assigned to the column 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 | VariableType, str | None | VariableType] | VariableType DEFAULT: None

type

Column type spec (with metadata) as SQL text. Not supported for VIEW table_type

TYPE: str | None | VariableType DEFAULT: None

type_json

TYPE: str | None | VariableType DEFAULT: None


laktory.models.resources.databricks.table.TableLookup ¤

Bases: ResourceLookup

PARAMETER DESCRIPTION
name

Full name of the databricks_table: catalog.schema.table

TYPE: str | VariableType