delta_engine.schema¶
Public schema declaration surface.
Import table declarations, columns, data types, properties, and key helpers from here when defining desired Delta table schemas.
Attributes¶
Classes¶
Defines a Delta table schema. |
|
Public declaration of a foreign key relationship. |
|
The Delta table properties a user may declare on a table. |
|
Array of homogeneous |
|
Sequence-of-bytes type. |
|
Boolean truth value type. |
|
8-bit signed integer type (TINYINT). |
|
Calendar date without time or timezone. |
|
Fixed-precision decimal type. |
|
Immutable column declaration with a canonical-lowercase name. |
|
64-bit floating point type. |
|
32-bit floating point type. |
|
32-bit signed integer type. |
|
64-bit signed integer type. |
|
Dictionary of |
|
16-bit signed integer type (SMALLINT). |
|
Unicode string type. |
|
Struct of named fields; identity is the ordered (name, type) tuple. |
|
One named field inside a |
|
Timestamp with date and time (timezone handling is engine-specific). |
|
Timestamp with date and time, no timezone. |
|
Semi-structured value type (Databricks VARIANT). |
Module Contents¶
- class DeltaTable(catalog: str, schema: str, name: str, columns: collections.abc.Iterable[delta_engine.domain.model.DesiredColumn], comment: str = '', properties: collections.abc.Mapping[str, str | None] | None = None, tags: collections.abc.Mapping[str, str] | None = None, partitioned_by: collections.abc.Iterable[str] = (), clustered_by: collections.abc.Iterable[str] = (), primary_key: collections.abc.Sequence[str] | None = None, foreign_keys: collections.abc.Iterable[ForeignKey] | None = None, scope: Literal['full', 'metadata', 'tags'] = 'full')¶
Defines a Delta table schema.
scopeselects how much of the table the declaration manages: the whole table (default), catalog metadata only, or tags only.Note on dropping columns: Delta only permits
ALTER TABLE ... DROP COLUMNwhendelta.columnMapping.modeisname. Declare it inpropertieson any table whose columns may be dropped; a sync that drops a column without it fails at validation with a message naming the property.- property catalog: str¶
Unity Catalog catalog name.
- property schema: str¶
Schema (database) name within the catalog.
- property name: str¶
Table name.
- property columns: tuple[delta_engine.domain.model.DesiredColumn, Ellipsis]¶
Declared columns, in declaration order.
- property comment: str¶
Table-level comment (empty string when unset).
- property properties: collections.abc.Mapping[str, str | None]¶
Declared table properties.
A
Nonevalue asserts the property must be absent from the table.
- property tags: collections.abc.Mapping[str, str]¶
Declared table tags.
- property partitioned_by: tuple[str, Ellipsis]¶
Partition column names, in declaration order.
- property clustered_by: tuple[str, Ellipsis]¶
Clustering key column names, in declaration order.
- property primary_key: tuple[str, Ellipsis]¶
Column names declared as the primary key, in declaration order.
- property foreign_keys: tuple[delta_engine.domain.model.ForeignKeyConstraint, Ellipsis]¶
Foreign key constraints declared on this table.
- class ForeignKey¶
Public declaration of a foreign key relationship.
columnsaccepts one local column name for a single-column parent key, a sequence of local names for a same-name key, or an explicit{local: referenced}mapping. Sequence and mapping orders are irrelevant; ambiguous composite keys require the explicit form. Identifiers are normalized to lowercase when the declaration is constructed. The physical constraint name is generated by the engine and is not part of this declaration.referencesis anotherDeltaTable, or theSelfsentinel for a self-referential key. See the architecture explanation doc for why the reference is an object rather than a name. The referenced table must live in the same catalog as the declaring table — information_schema is per-catalog, so a cross-catalog constraint could be created but never observed afterwards.- columns: str | collections.abc.Sequence[str] | collections.abc.Mapping[str, str]¶
- references: DeltaTable | _SelfReference¶
- Self: Final¶
- class Property¶
Bases:
enum.StrEnumThe Delta table properties a user may declare on a table.
- COLUMN_MAPPING_MODE = 'delta.columnMapping.mode'¶
- CHANGE_DATA_FEED = 'delta.enableChangeDataFeed'¶
- DELETED_FILE_RETENTION_DURATION = 'delta.deletedFileRetentionDuration'¶
- LOG_RETENTION_DURATION = 'delta.logRetentionDuration'¶
- DATA_SKIPPING_NUM_INDEXED_COLS = 'delta.dataSkippingNumIndexedCols'¶
- TYPE_WIDENING = 'delta.enableTypeWidening'¶
- class Binary¶
Bases:
DataTypeSequence-of-bytes type.
- class Boolean¶
Bases:
DataTypeBoolean truth value type.
- class Byte¶
Bases:
DataType8-bit signed integer type (TINYINT).
- class Date¶
Bases:
DataTypeCalendar date without time or timezone.
- class Decimal¶
Bases:
DataTypeFixed-precision decimal type.
- Variables:
precision – Total number of digits (1-38, Delta/Spark limit).
scale – Digits to the right of the decimal point.
- precision: int¶
- scale: int = 0¶
- class Column¶
Immutable column declaration with a canonical-lowercase name.
Exposed to users as
Columnthroughdelta_engine.schema; the domain name states the desired/observed side explicitly, mirroringObservedColumn.- Variables:
name – Column name, lowercased on construction. Identifiers are case-insensitive on the platform, so two names differing only in case are the same column.
data_type – Logical data type of the column.
nullable – Whether the column accepts
NULLvalues.comment – Optional column comment.
tags – Read-only mapping of Unity Catalog column tag keys to values. Tag keys are case-sensitive and are stored verbatim (never lowercased, unlike the column name).
renamed_from – The column’s previous name, declaring a rename. Inert unless the old name is observed and the new one is not, so it is safe to keep on declarations that continue to manage column structure, and correct on fresh environments.
- name: str¶
- data_type: delta_engine.domain.model.data_type.DataType¶
- nullable: bool = True¶
- comment: str = ''¶
- tags: collections.abc.Mapping[str, str]¶
- renamed_from: str | None = None¶
- class Double¶
Bases:
DataType64-bit floating point type.
- class Float¶
Bases:
DataType32-bit floating point type.
- class Integer¶
Bases:
DataType32-bit signed integer type.
- class Long¶
Bases:
DataType64-bit signed integer type.
- class Short¶
Bases:
DataType16-bit signed integer type (SMALLINT).
- class String¶
Bases:
DataTypeUnicode string type.
- class Struct¶
Bases:
DataTypeStruct of named fields; identity is the ordered (name, type) tuple.
- fields: collections.abc.Sequence[StructField]¶
- class StructField¶
One named field inside a
Struct.Field nullability and comments are deliberately not modeled: catalog DDL strings do not round-trip them reliably, so both desired and observed structs normalize to name + type. Declared fields are created nullable.
- name: str¶
- data_type: DataType¶
- class Timestamp¶
Bases:
DataTypeTimestamp with date and time (timezone handling is engine-specific).
- class TimestampNtz¶
Bases:
DataTypeTimestamp with date and time, no timezone.
- class Variant¶
Bases:
DataTypeSemi-structured value type (Databricks VARIANT).