Transactions#
- class ducklake.transaction.Transaction[source]#
Methods:
Create a new table as part of this transaction.
- create_table(
- name: str | tuple[str, str] | TableName,
- schema: Schema | Sequence[Column] | Mapping[str, DataType],
- partition_by: Partitioning | Sequence[PartitionColumn] | Sequence[str] | PartitionColumn | str | None = None,
- data_path: str | None = None,
- tags: Mapping[str, str] | None = None,
Create a new table as part of this transaction.
The table (and any subsequent changes or writes against it) only becomes visible once the transaction is committed.
- Parameters:
name – The fully qualified name of the new table.
schema – The schema of the new table.
partition_by – Optional partitioning for the table.
data_path – Optional data path for the table.
tags – Optional tags to attach to the table.
- Returns:
A
TransactionTablereferring to the newly created table.
- class ducklake.transaction.TransactionTable[source]#
Methods:
Add a new column to the table.
Add a new tag to a column.
Add a new tag to the table.
Delete the table from the catalog.
Remove a column from the table.
Remove an existing tag from a column.
Remove an existing tag from the table.
Rename the table in the catalog.
Rename a column in the table.
Update the default value of a column.
Update the data type of the provided column.
Update the nullability of a column.
Update the partitioning of this table.
Update the full schema of the table.
Attributes:
The partitioning of the table, if any.
The schema of the table.
- add_column(column: Column) None[source]#
Add a new column to the table.
- Parameters:
column – The column to add.
- add_column_tag( ) None[source]#
Add a new tag to a column.
- Parameters:
column – The name of the column to add the tag to. This may be provided as a “path” to a nested column.
key – The key of the tag.
value – The value of the tag.
- add_tag(key: str, value: str) None[source]#
Add a new tag to the table.
- Parameters:
key – The key of the tag.
value – The value of the tag.
- delete() None[source]#
Delete the table from the catalog.
After calling this method, the
TransactionTableobject is no longer valid.
- property partitioning: Partitioning | None#
The partitioning of the table, if any.
- remove_column(column: str | Sequence[str]) None[source]#
Remove a column from the table.
- Parameters:
column – The name of the column to remove. This may be provided as a “path” to a nested column.
- remove_column_tag(column: str | Sequence[str], key: str) None[source]#
Remove an existing tag from a column.
- Parameters:
column – The name of the column to remove the tag from. This may be provided as a “path” to a nested column.
key – The key of the tag.
- Raises:
ValueError – If no tag for the provided key exists.
- remove_tag(key: str) None[source]#
Remove an existing tag from the table.
- Parameters:
key – The key of the tag.
- Raises:
ValueError – If no tag for the provided key exists.
- rename(new_name: str) None[source]#
Rename the table in the catalog.
- Parameters:
new_name – The new name for the table.
Note
This operation does not affect the schema the table resides in. It is not currently possible to move a table to a different schema.
- rename_column(column: str | Sequence[str], new_name: str) None[source]#
Rename a column in the table.
- Parameters:
column – The current name of the column to rename. This may be provided as a “path” to a nested column.
new_name – The new name for the column.
- update_column_default( ) None[source]#
Update the default value of a column.
The default value can be a literal value, or an expression specified as a
(dialect, expression)tuple. PassNoneto remove the default.- Parameters:
column – The column for which to change the default value.
default_value – The new default value.
- update_column_dtype( ) None[source]#
Update the data type of the provided column.
Generally speaking, data types can only be changed via type promotion. For example, integers can be turned into larger integers.
For struct columns, updating the data type allows adding and dropping fields.
- Parameters:
column – The column for which to change the data type.
new_dtype – The new data type of the column.
- update_column_nullability(column: str, nullable: bool) None[source]#
Update the nullability of a column.
- Parameters:
column – The column for which to change the nullability.
nullable – Whether the column should allow null values.
- update_partitioning(
- partitioning: Partitioning | None,
Update the partitioning of this table.
- Parameters:
partitioning – The new partitioning. If
Noneis provided, the partitioning of the table is reset.
Note
This is a metadata-only operation which does not rewrite data files. As a result, queries might not be fully optimized.