gravitino.api.rel.table_change.TableChange¶
- class gravitino.api.rel.table_change.TableChange¶
Bases:
ABCDefines the public APIs for managing tables in a schema.
The TableChange interface defines the public API for managing tables in a schema. If the catalog implementation supports tables, it must implement this interface.
- __init__()¶
Methods
__init__()add_column(field_name, data_type[, comment, ...])Create a TableChange for adding a column.
add_index(index_type, name, field_names)Create a TableChange for adding an index.
delete_column(field_name, if_exists)Create a TableChange for deleting a field.
delete_index(name, if_exists)Create a TableChange for deleting an index.
remove_property(property_name)Create a TableChange for removing a table property.
rename(new_name)Create a TableChange for renaming a table.
rename_column(field_name, new_name)Create a TableChange for renaming a field.
set_property(property_name, value)Create a TableChange for setting a table property.
update_column_auto_increment(field_name, ...)Create a TableChange for updating the autoIncrement of a field.
update_column_comment(field_name, new_comment)Create a TableChange for updating the comment of a field.
update_column_default_value(field_name, ...)Create a TableChange for updating the default value of a field.
update_column_nullability(field_name, nullable)Create a TableChange for updating the nullability of a field.
update_column_position(field_name, new_position)Create a TableChange for updating the position of a field.
update_column_type(field_name, new_data_type)Create a TableChange for updating the type of a field that is nullable.
update_comment(new_comment)Create a TableChange for updating the comment.
- final class AddIndex(_type: IndexType, _name: str, _field_names: list[list[str]])¶
Bases:
objectA TableChange to add an index.
Add an index key based on the type and field name passed in as well as the name.
- get_field_names() list[list[str]]¶
Retrieves the field names of the index.
- Returns:
list[list[str]]: The field names of the index.
- get_name() str¶
Retrieves the name of the index.
- Returns:
str: The name of the index.
- class ColumnChange¶
Bases:
ABCThe interface for all column changes.
Column changes are used to modify the schema of a table.
- abstract field_name() list[str]¶
Retrieves the field name of the column to be modified.
- Returns:
- list[str]:
A list of strings representing the field name.
- class ColumnPosition¶
Bases:
ABCThe interface for all column positions.
Column positions are used to specify the position of a column when adding a new column to a table.
- static after(column: str) After¶
Returns the position after the given column.
- Args:
- column:
The name of the reference column to place the new column after.
- Returns:
- After:
The position after the given column.
- final class DeleteIndex(_name: str, _if_exists: bool)¶
Bases:
objectA TableChange to delete an index.
If the index does not exist, the change must result in an IllegalArgumentException.
- get_name() str¶
Retrieves the name of the index to be deleted.
- Returns:
str: The name of the index to be deleted.
- is_if_exists() bool¶
Retrieves the value of the if_exists flag.
- Returns:
bool: True if the index should be deleted if it exists, False otherwise.
- final class RemoveProperty(_property: str)¶
Bases:
objectA TableChange to remove a table property.
If the property does not exist, the change should succeed.
- get_property() str¶
Retrieves the name of the property to be removed from the table.
- Returns:
str: The name of the property scheduled for removal.
- final class RenameTable(_new_name: str)¶
Bases:
objectA TableChange to rename a table.
- get_new_name() str¶
Retrieves the new name for the table.
- Returns:
str: The new name of the table.
- final class SetProperty(_property: str, _value: str)¶
Bases:
objectA TableChange to set a table property.
- get_property() str¶
Retrieves the name of the property.
- Returns:
str: The name of the property.
- get_value() str¶
Retrieves the value of the property.
- Returns:
str: The value of the property.
- final class UpdateComment(_new_comment: str)¶
Bases:
objectA TableChange to update a table’s comment.
- get_new_comment() str¶
Retrieves the new comment for the table.
- Returns:
str: The new comment of the table.
- static add_column(field_name: list[str], data_type: Type, comment: str | None = None, position: ColumnPosition | None = None, nullable: bool = True, auto_increment: bool = False, default_value: Expression | None = None) AddColumn¶
Create a TableChange for adding a column.
- Args:
- field_name (list[str]):
Field name of the new column.
- data_type (Type):
The new column’s data type.
- comment (Optional[str]):
The new field’s comment string, defaults to None.
- position (Optional[TableChange.ColumnPosition]):
The new column’s position, defaults to None.
- nullable (bool):
The new column’s nullable.
- auto_increment (bool):
The new column’s autoIncrement.
- default_value (Expression):
The new column’s default value.
- Returns:
AddColumn: A TableChange for the addition.
- static add_index(index_type: IndexType, name: str, field_names: list[list[str]]) AddIndex¶
Create a TableChange for adding an index.
- Args:
index_type (Index.IndexType): The type of the index. name (str): The name of the index. field_names (list[list[str]]): The field names of the index.
- Returns:
TableChange: A TableChange for the add index.
- static delete_column(field_name: list[str], if_exists: bool) DeleteColumn¶
Create a TableChange for deleting a field.
If the field does not exist, the change will result in an IllegalArgumentException unless if_exists is true.
- Args:
field_name (list[str]): Field name of the column to delete. if_exists (bool): If true, silence the error if column does not exist during drop.
Otherwise, an IllegalArgumentException will be thrown.
- Returns:
TableChange: A TableChange for the delete.
- static delete_index(name: str, if_exists: bool) DeleteIndex¶
Create a TableChange for deleting an index.
- Args:
name (str): The name of the index to be dropped. if_exists (bool): If true, silence the error if column does not exist during drop.
Otherwise, an IllegalArgumentException will be thrown.
- Returns:
TableChange: A TableChange for the delete index.
- static remove_property(property_name: str) RemoveProperty¶
Create a TableChange for removing a table property.
If the property does not exist, the change will succeed.
- Args:
property_name (str): The property name.
- Returns:
RemoveProperty: A TableChange for the addition.
- static rename(new_name: str) RenameTable¶
Create a TableChange for renaming a table.
- Args:
new_name: The new table name.
- Returns:
RenameTable: A TableChange for the rename.
- static rename_column(field_name: list[str], new_name: str) RenameColumn¶
Create a TableChange for renaming a field.
The name is used to find the field to rename. The new name will replace the leaf field name. For example, rename_column([“a”, “b”, “c”], “x”) should produce column a.b.x.
If the field does not exist, the change will result in an IllegalArgumentException.
- Args:
field_name (list[str]): The current field name. new_name (str): The new name.
- Returns:
RenameColumn: A TableChange for the rename.
- static set_property(property_name: str, value: str) SetProperty¶
Create a TableChange for setting a table property.
If the property already exists, it will be replaced with the new value.
- Args:
property_name (str): The property name. value (str): The new property value.
- Returns:
SetProperty: A TableChange for the addition.
- static update_column_auto_increment(field_name: list[str], auto_increment: bool) UpdateColumnAutoIncrement¶
Create a TableChange for updating the autoIncrement of a field.
The name is used to find the field to update.
If the field does not exist, the change will result in an IllegalArgumentException.
- Args:
field_name (list[str]): The field name of the column to update. auto_increment (bool): The new autoIncrement.
- Returns:
TableChange: A TableChange for the update.
- static update_column_comment(field_name: list[str], new_comment: str) UpdateColumnComment¶
Create a TableChange for updating the comment of a field.
The name is used to find the field to update.
If the field does not exist, the change will result in an IllegalArgumentException.
- Args:
field_name (list[str]): The field name of the column to update. new_comment (str): The new comment.
- Returns:
TableChange: A TableChange for the update.
- static update_column_default_value(field_name: list[str], new_default_value: Expression) UpdateColumnDefaultValue¶
Create a TableChange for updating the default value of a field.
The name is used to find the field to update.
If the field does not exist, the change will result in an IllegalArgumentException.
- Args:
field_name (list[str]): The field name of the column to update. new_default_value (Expression): The new default value.
- Returns:
TableChange: A TableChange for the update.
- static update_column_nullability(field_name: list[str], nullable: bool) UpdateColumnNullability¶
Create a TableChange for updating the nullability of a field.
The name is used to find the field to update.
If the field does not exist, the change will result in an IllegalArgumentException.
- Args:
field_name (list[str]): The field name of the column to update. nullable (bool): The new nullability.
- Returns:
TableChange: A TableChange for the update.
- static update_column_position(field_name: list[str], new_position: ColumnPosition) UpdateColumnPosition¶
Create a TableChange for updating the position of a field.
The name is used to find the field to update.
If the field does not exist, the change will result in an IllegalArgumentException.
- Args:
field_name (list[str]): The field name of the column to update. new_position (TableChange.ColumnPosition): The new position.
- Returns:
TableChange: A TableChange for the update.
- static update_column_type(field_name: list[str], new_data_type: Type) UpdateColumnType¶
Create a TableChange for updating the type of a field that is nullable.
The field name are used to find the field to update.
If the field does not exist, the change will result in an IllegalArgumentException.
- Args:
field_name (list[str]): The field name of the column to update. new_data_type (Type): The new data type.
- Returns:
TableChange: A TableChange for the update.
- static update_comment(new_comment: str) UpdateComment¶
Create a TableChange for updating the comment.
- Args:
new_comment: The new comment.
- Returns:
UpdateComment: A TableChange for the update.