Interface TableChange
- All Known Subinterfaces:
TableChange.ColumnChange
- All Known Implementing Classes:
TableChange.AddColumn,TableChange.AddIndex,TableChange.DeleteColumn,TableChange.DeleteIndex,TableChange.RemoveProperty,TableChange.RenameColumn,TableChange.RenameTable,TableChange.SetProperty,TableChange.UpdateColumnAutoIncrement,TableChange.UpdateColumnComment,TableChange.UpdateColumnDefaultValue,TableChange.UpdateColumnNullability,TableChange.UpdateColumnPosition,TableChange.UpdateColumnType,TableChange.UpdateComment
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classA TableChange to add a field.static final classA TableChange to add an index.static final classColumn position AFTER means the specified column should be put after the given `column`.static interfaceThe interface for all column changes.static interfaceThe interface for all column positions.static final classColumn position DEFAULT means the position of the column was ignored by the user, and should be determined by the catalog implementation.static final classA TableChange to delete a field.static final classA TableChange to delete an index.static final classColumn position FIRST means the specified column should be the first column.static final classA TableChange to remove a table property.static final classA TableChange to rename a field.static final classA TableChange to rename a table.static final classA TableChange to set a table property.static final classA TableChange to update the autoIncrement of a field.static final classA TableChange to update the comment of a field.static final classA TableChange to update the default of a field.static final classA TableChange to update the nullability of a field.static final classA TableChange to update the position of a field.static final classA TableChange to update the type of a field.static final classA TableChange to update a table's comment. -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic TableChangeCreate a TableChange for adding an optional column.static TableChangeCreate a TableChange for adding a column.static TableChangeCreate a TableChange for adding a column.static TableChangeCreate a TableChange for adding a column.static TableChangeaddColumn(String[] fieldName, Type dataType, String comment, Expression defaultValue) Create a TableChange for adding a column.static TableChangeaddColumn(String[] fieldName, Type dataType, String comment, TableChange.ColumnPosition position) Create a TableChange for adding a column.static TableChangeaddColumn(String[] fieldName, Type dataType, String comment, TableChange.ColumnPosition position, boolean nullable) Create a TableChange for adding a column.static TableChangeaddColumn(String[] fieldName, Type dataType, String comment, TableChange.ColumnPosition position, boolean nullable, boolean autoIncrement) Create a TableChange for adding a column.static TableChangeaddColumn(String[] fieldName, Type dataType, String comment, TableChange.ColumnPosition position, boolean nullable, boolean autoIncrement, Expression defaultValue) Create a TableChange for adding a column.static TableChangeaddColumn(String[] fieldName, Type dataType, String comment, TableChange.ColumnPosition position, Expression defaultValue) Create a TableChange for adding a column.static TableChangeaddColumn(String[] fieldName, Type dataType, Expression defaultValue) Create a TableChange for adding a column.static TableChangeaddColumn(String[] fieldName, Type dataType, TableChange.ColumnPosition position) Create a TableChange for adding a column.static TableChangeaddColumn(String[] fieldName, Type dataType, TableChange.ColumnPosition position, Expression defaultValue) Create a TableChange for adding a column.static TableChangeaddIndex(Index.IndexType type, String name, String[][] fieldNames) Create a TableChange for adding an index.static TableChangedeleteColumn(String[] fieldName, Boolean ifExists) Create a TableChange for deleting a field.static TableChangedeleteIndex(String name, Boolean ifExists) Create a TableChange for deleting an index.static TableChangeremoveProperty(String property) Create a TableChange for removing a table property.static TableChangeCreate a TableChange for renaming a table.static TableChangerenameColumn(String[] fieldName, String newName) Create a TableChange for renaming a field.static TableChangesetProperty(String property, String value) Create a TableChange for setting a table property.static TableChangeupdateColumnAutoIncrement(String[] fieldName, boolean autoIncrement) Create a TableChange for updating the autoIncrement of a field.static TableChangeupdateColumnComment(String[] fieldName, String newComment) Create a TableChange for updating the comment of a field.static TableChangeupdateColumnDefaultValue(String[] fieldName, Expression newDefaultValue) Create a TableChange for updating the default value of a field.static TableChangeupdateColumnNullability(String[] fieldName, boolean nullable) Create a TableChange for updating the nullability of a field.static TableChangeupdateColumnPosition(String[] fieldName, TableChange.ColumnPosition newPosition) Create a TableChange for updating the position of a field.static TableChangeupdateColumnType(String[] fieldName, Type newDataType) Create a TableChange for updating the type of a field that is nullable.static TableChangeupdateComment(String newComment) Create a TableChange for updating the comment.
-
Method Details
-
rename
Create a TableChange for renaming a table.- Parameters:
newName- The new table name.- Returns:
- A TableChange for the rename.
-
updateComment
Create a TableChange for updating the comment.- Parameters:
newComment- The new comment.- Returns:
- A TableChange for the update.
-
setProperty
Create a TableChange for setting a table property.If the property already exists, it will be replaced with the new value.
- Parameters:
property- The property name.value- The new property value.- Returns:
- A TableChange for the addition.
-
removeProperty
Create a TableChange for removing a table property.If the property does not exist, the change will succeed.
- Parameters:
property- The property name.- Returns:
- A TableChange for the addition.
-
addColumn
Create a TableChange for adding an optional column.If the field already exists, the change will result in an
IllegalArgumentException. If the new field is nested and its parent does not exist or is not a struct, the change will result in anIllegalArgumentException.- Parameters:
fieldName- The field name of the new column.dataType- The new column's data type.- Returns:
- A TableChange for the addition.
-
addColumn
Create a TableChange for adding a column.If the field already exists, the change will result in an
IllegalArgumentException. If the new field is nested and its parent does not exist or is not a struct, the change will result in anIllegalArgumentException.- Parameters:
fieldName- The field name of the new column.dataType- The new column's data type.comment- The new field's comment string.- Returns:
- A TableChange for the addition.
-
addColumn
static TableChange addColumn(String[] fieldName, Type dataType, TableChange.ColumnPosition position) Create a TableChange for adding a column.If the field already exists, the change will result in an
IllegalArgumentException. If the new field is nested and its parent does not exist or is not a struct, the change will result in anIllegalArgumentException.- Parameters:
fieldName- The field name of the new column.dataType- The new column's data type.position- The new column's position.- Returns:
- A TableChange for the addition.
-
addColumn
static TableChange addColumn(String[] fieldName, Type dataType, String comment, TableChange.ColumnPosition position) Create a TableChange for adding a column.If the field already exists, the change will result in an
IllegalArgumentException. If the new field is nested and its parent does not exist or is not a struct, the change will result in anIllegalArgumentException.- Parameters:
fieldName- Field name of the new column.dataType- The new column's data type.comment- The new field's comment string.position- The new column's position.- Returns:
- A TableChange for the addition.
-
addColumn
Create a TableChange for adding a column.If the field already exists, the change will result in an
IllegalArgumentException. If the new field is nested and its parent does not exist or is not a struct, the change will result in anIllegalArgumentException.- Parameters:
fieldName- Field name of the new column.dataType- The new column's data type.nullable- The new column's nullable.- Returns:
- A TableChange for the addition.
-
addColumn
Create a TableChange for adding a column.- Parameters:
fieldName- Field name of the new column.dataType- The new column's data type.comment- The new field's comment string.nullable- The new column's nullable.- Returns:
- A TableChange for the addition.
-
addColumn
Create a TableChange for adding a column.- Parameters:
fieldName- Field name of the new column.dataType- The new column's data type.defaultValue- The new column's default value.- Returns:
- A TableChange for the addition.
-
addColumn
static TableChange addColumn(String[] fieldName, Type dataType, String comment, Expression defaultValue) Create a TableChange for adding a column.- Parameters:
fieldName- Field name of the new column.dataType- The new column's data type.comment- The new field's comment string.defaultValue- The new column's default value.- Returns:
- A TableChange for the addition.
-
addColumn
static TableChange addColumn(String[] fieldName, Type dataType, TableChange.ColumnPosition position, Expression defaultValue) Create a TableChange for adding a column.- Parameters:
fieldName- Field name of the new column.dataType- The new column's data type.position- The new column's position.defaultValue- The new column's default value.- Returns:
- A TableChange for the addition.
-
addColumn
static TableChange addColumn(String[] fieldName, Type dataType, String comment, TableChange.ColumnPosition position, Expression defaultValue) Create a TableChange for adding a column.- Parameters:
fieldName- Field name of the new column.dataType- The new column's data type.comment- The new field's comment string.position- The new column's position.defaultValue- The new column's default value.- Returns:
- A TableChange for the addition.
-
addColumn
static TableChange addColumn(String[] fieldName, Type dataType, String comment, TableChange.ColumnPosition position, boolean nullable) Create a TableChange for adding a column.If the field already exists, the change will result in an
IllegalArgumentException. If the new field is nested and its parent does not exist or is not a struct, the change will result in anIllegalArgumentException.- Parameters:
fieldName- Field name of the new column.dataType- The new column's data type.comment- The new field's comment string.position- The new column's position.nullable- The new column's nullable.- Returns:
- A TableChange for the addition.
-
addColumn
static TableChange addColumn(String[] fieldName, Type dataType, String comment, TableChange.ColumnPosition position, boolean nullable, boolean autoIncrement) Create a TableChange for adding a column.If the field already exists, the change will result in an
IllegalArgumentException. If the new field is nested and its parent does not exist or is not a struct, the change will result in anIllegalArgumentException.- Parameters:
fieldName- Field name of the new column.dataType- The new column's data type.comment- The new field's comment string.position- The new column's position.nullable- The new column's nullable.autoIncrement- The new column's autoIncrement.- Returns:
- A TableChange for the addition.
-
addColumn
static TableChange addColumn(String[] fieldName, Type dataType, String comment, TableChange.ColumnPosition position, boolean nullable, boolean autoIncrement, Expression defaultValue) Create a TableChange for adding a column.If the field already exists, the change will result in an
IllegalArgumentException. If the new field is nested and its parent does not exist or is not a struct, the change will result in anIllegalArgumentException.- Parameters:
fieldName- Field name of the new column.dataType- The new column's data type.comment- The new field's comment string.position- The new column's position.nullable- The new column's nullable.autoIncrement- The new column's autoIncrement.defaultValue- The new column's default value.- Returns:
- A TableChange for the addition.
-
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, renameColumn(["a", "b", "c"], "x") should produce column a.b.x.
If the field does not exist, the change will result in an
IllegalArgumentException.- Parameters:
fieldName- The current field name.newName- The new name.- Returns:
- A TableChange for the rename.
-
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.- Parameters:
fieldName- The field name of the column to update.newDefaultValue- The new default value.- Returns:
- A TableChange for the update.
-
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.- Parameters:
fieldName- The field name of the column to update.newDataType- The new data type.- Returns:
- A TableChange for the update.
-
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.- Parameters:
fieldName- The field name of the column to update.newComment- The new comment.- Returns:
- A TableChange for the update.
-
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.- Parameters:
fieldName- The field name of the column to update.newPosition- The new position.- Returns:
- A TableChange for the update.
-
deleteColumn
Create a TableChange for deleting a field.If the field does not exist, the change will result in an
IllegalArgumentExceptionunlessifExistsis true.- Parameters:
fieldName- Field name of the column to delete.ifExists- If true, silence the error if column does not exist during drop. Otherwise, anIllegalArgumentExceptionwill be thrown.- Returns:
- A TableChange for the delete.
-
updateColumnNullability
Create a TableChange for updating the nullability of a field.The name are used to find the field to update.
If the field does not exist, the change will result in an
IllegalArgumentException.- Parameters:
fieldName- The field name of the column to update.nullable- The new nullability.- Returns:
- A TableChange for the update.
-
addIndex
Create a TableChange for adding an index.- Parameters:
type- The type of the index.name- The name of the index.fieldNames- The field names of the index.- Returns:
- A TableChange for the add index.
-
deleteIndex
Create a TableChange for deleting an index.- Parameters:
name- The name of the index to be dropped.ifExists- If true, silence the error if column does not exist during drop. Otherwise, anIllegalArgumentExceptionwill be thrown.- Returns:
- A TableChange for the delete index.
-
updateColumnAutoIncrement
Create a TableChange for updating the autoIncrement of a field.- Parameters:
fieldName- The field name of the column to update.autoIncrement- Whether the column is auto-incremented.- Returns:
- A TableChange for the update.
-