TableAlterer
deltalake.table.TableAlterer
API for various table alteration commands.
add_columns
add_columns(fields: Union[DeltaField, List[DeltaField]], custom_metadata: Optional[Dict[str, str]] = None, commit_properties: Optional[CommitProperties] = None, post_commithook_properties: Optional[PostCommitHookProperties] = None) -> None
Add new columns and/or update the fields of a stuctcolumn
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fields |
Union[Field, List[Field]]
|
fields to merge into schema |
required |
commit_properties |
Optional[CommitProperties]
|
properties of the transaction commit. If None, default values are used. |
None
|
post_commithook_properties |
Optional[PostCommitHookProperties]
|
properties for the post commit hook. If None, default values are used. |
None
|
Example
from deltalake.schema import Field, PrimitiveType, StructType dt = DeltaTable("test_table") new_fields = [ Field("baz", StructType([Field("bar", PrimitiveType("integer"))])), Field("bar", PrimitiveType("integer")) ] dt.alter.add_columns( new_fields ) ```
add_constraint
add_constraint(constraints: Dict[str, str], custom_metadata: Optional[Dict[str, str]] = None, post_commithook_properties: Optional[PostCommitHookProperties] = None, commit_properties: Optional[CommitProperties] = None) -> None
Add constraints to the table. Limited to single constraint
at once.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
constraints |
Dict[str, str]
|
mapping of constraint name to SQL-expression to evaluate on write |
required |
custom_metadata |
Optional[Dict[str, str]]
|
Deprecated and will be removed in future versions. Use commit_properties instead. |
None
|
post_commithook_properties |
Optional[PostCommitHookProperties]
|
properties for the post commit hook. If None, default values are used. |
None
|
commit_properties |
Optional[CommitProperties]
|
properties of the transaction commit. If None, default values are used. |
None
|
add_feature
add_feature(feature: Union[TableFeatures, List[TableFeatures]], allow_protocol_versions_increase: bool = False, commit_properties: Optional[CommitProperties] = None, post_commithook_properties: Optional[PostCommitHookProperties] = None) -> None
Enable a table feature.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feature |
Union[TableFeatures, List[TableFeatures]]
|
Table Feature e.g. Deletion Vectors, Change Data Feed |
required |
allow_protocol_versions_increase |
bool
|
Allow the protocol to be implicitily bumped to reader 3 or writer 7 |
False
|
commit_properties |
Optional[CommitProperties]
|
properties of the transaction commit. If None, default values are used. |
None
|
post_commithook_properties |
Optional[PostCommitHookProperties]
|
properties for the post commit hook. If None, default values are used. |
None
|
drop_constraint
drop_constraint(name: str, raise_if_not_exists: bool = True, custom_metadata: Optional[Dict[str, str]] = None, post_commithook_properties: Optional[PostCommitHookProperties] = None, commit_properties: Optional[CommitProperties] = None) -> None
Drop constraints from a table. Limited to single constraint
at once.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
constraint name which to drop. |
required |
raise_if_not_exists |
bool
|
set if should raise if not exists. |
True
|
custom_metadata |
Optional[Dict[str, str]]
|
Deprecated and will be removed in future versions. Use commit_properties instead. |
None
|
post_commithook_properties |
Optional[PostCommitHookProperties]
|
properties for the post commit hook. If None, default values are used. |
None
|
commit_properties |
Optional[CommitProperties]
|
properties of the transaction commit. If None, default values are used. |
None
|
set_table_properties
set_table_properties(properties: Dict[str, str], raise_if_not_exists: bool = True, custom_metadata: Optional[Dict[str, str]] = None, commit_properties: Optional[CommitProperties] = None) -> None
Set properties from the table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
properties |
Dict[str, str]
|
properties which set |
required |
raise_if_not_exists |
bool
|
set if should raise if not exists. |
True
|
custom_metadata |
Optional[Dict[str, str]]
|
Deprecated and will be removed in future versions. Use commit_properties instead. |
None
|
commit_properties |
Optional[CommitProperties]
|
properties of the transaction commit. If None, default values are used. |
None
|