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

@Evolving public interface TableChange
The TableChange interface defines the public API for managing tables in a schema. If the catalog implementation supports tables, it must implement this interface.
  • Method Details

    • rename

      static TableChange rename(String newName)
      Create a TableChange for renaming a table.
      Parameters:
      newName - The new table name.
      Returns:
      A TableChange for the rename.
    • updateComment

      static TableChange updateComment(String newComment)
      Create a TableChange for updating the comment.
      Parameters:
      newComment - The new comment.
      Returns:
      A TableChange for the update.
    • setProperty

      static TableChange setProperty(String property, String value)
      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

      static TableChange removeProperty(String property)
      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

      static TableChange addColumn(String[] fieldName, Type dataType)
      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 an IllegalArgumentException.

      Parameters:
      fieldName - The field name of the new column.
      dataType - The new column's data type.
      Returns:
      A TableChange for the addition.
    • addColumn

      static TableChange addColumn(String[] fieldName, Type dataType, String comment)
      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 an IllegalArgumentException.

      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 an IllegalArgumentException.

      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 an IllegalArgumentException.

      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

      static TableChange addColumn(String[] fieldName, Type dataType, 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 an IllegalArgumentException.

      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

      static TableChange addColumn(String[] fieldName, Type dataType, String comment, boolean nullable)
      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

      static TableChange addColumn(String[] fieldName, Type dataType, Expression defaultValue)
      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 an IllegalArgumentException.

      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 an IllegalArgumentException.

      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 an IllegalArgumentException.

      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

      static TableChange renameColumn(String[] fieldName, String newName)
      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

      static TableChange updateColumnDefaultValue(String[] fieldName, Expression newDefaultValue)
      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

      static TableChange updateColumnType(String[] fieldName, Type newDataType)
      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

      static TableChange updateColumnComment(String[] fieldName, String newComment)
      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

      static TableChange updateColumnPosition(String[] fieldName, TableChange.ColumnPosition newPosition)
      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

      static TableChange deleteColumn(String[] fieldName, Boolean ifExists)
      Create a TableChange for deleting a field.

      If the field does not exist, the change will result in an IllegalArgumentException unless ifExists is true.

      Parameters:
      fieldName - Field name of the column to delete.
      ifExists - If true, silence the error if column does not exist during drop. Otherwise, an IllegalArgumentException will be thrown.
      Returns:
      A TableChange for the delete.
    • updateColumnNullability

      static TableChange updateColumnNullability(String[] fieldName, boolean nullable)
      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

      static TableChange addIndex(Index.IndexType type, String name, String[][] fieldNames)
      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

      static TableChange deleteIndex(String name, Boolean ifExists)
      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, an IllegalArgumentException will be thrown.
      Returns:
      A TableChange for the delete index.
    • updateColumnAutoIncrement

      static TableChange updateColumnAutoIncrement(String[] fieldName, boolean autoIncrement)
      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.