@Experimental
public interface TableChange
TableCatalog.alterTable(org.apache.spark.sql.connector.catalog.Identifier, org.apache.spark.sql.connector.catalog.TableChange...). For example,
import TableChange._
val catalog = Catalogs.load(name)
catalog.asTableCatalog.alterTable(ident,
addColumn("x", IntegerType),
renameColumn("a", "b"),
deleteColumn("c")
)
| Modifier and Type | Interface and Description |
|---|---|
static class |
TableChange.AddColumn
A TableChange to add a field.
|
static interface |
TableChange.ColumnChange |
static class |
TableChange.DeleteColumn
A TableChange to delete a field.
|
static class |
TableChange.RemoveProperty
A TableChange to remove a table property.
|
static class |
TableChange.RenameColumn
A TableChange to rename a field.
|
static class |
TableChange.SetProperty
A TableChange to set a table property.
|
static class |
TableChange.UpdateColumnComment
A TableChange to update the comment of a field.
|
static class |
TableChange.UpdateColumnType
A TableChange to update the type of a field.
|
| Modifier and Type | Method and Description |
|---|---|
static TableChange |
addColumn(String[] fieldNames,
DataType dataType)
Create a TableChange for adding an optional column.
|
static TableChange |
addColumn(String[] fieldNames,
DataType dataType,
boolean isNullable)
Create a TableChange for adding a column.
|
static TableChange |
addColumn(String[] fieldNames,
DataType dataType,
boolean isNullable,
String comment)
Create a TableChange for adding a column.
|
static TableChange |
deleteColumn(String[] fieldNames)
Create a TableChange for deleting a field.
|
static TableChange |
removeProperty(String property)
Create a TableChange for removing a table property.
|
static TableChange |
renameColumn(String[] fieldNames,
String newName)
Create a TableChange for renaming a field.
|
static TableChange |
setProperty(String property,
String value)
Create a TableChange for setting a table property.
|
static TableChange |
updateColumnComment(String[] fieldNames,
String newComment)
Create a TableChange for updating the comment of a field.
|
static TableChange |
updateColumnType(String[] fieldNames,
DataType newDataType)
Create a TableChange for updating the type of a field that is nullable.
|
static TableChange |
updateColumnType(String[] fieldNames,
DataType newDataType,
boolean isNullable)
Create a TableChange for updating the type of a field.
|
static TableChange setProperty(String property, String value)
If the property already exists, it will be replaced with the new value.
property - the property namevalue - the new property valuestatic TableChange removeProperty(String property)
If the property does not exist, the change will succeed.
property - the property namestatic TableChange addColumn(String[] fieldNames, DataType dataType)
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.
fieldNames - field names of the new columndataType - the new column's data typestatic TableChange addColumn(String[] fieldNames, DataType dataType, boolean isNullable)
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.
fieldNames - field names of the new columndataType - the new column's data typeisNullable - whether the new column can contain nullstatic TableChange addColumn(String[] fieldNames, DataType dataType, boolean isNullable, String comment)
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.
fieldNames - field names of the new columndataType - the new column's data typeisNullable - whether the new column can contain nullcomment - the new field's comment stringstatic TableChange renameColumn(String[] fieldNames, String newName)
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.
fieldNames - the current field namesnewName - the new namestatic TableChange updateColumnType(String[] fieldNames, DataType newDataType)
The field names are used to find the field to update.
If the field does not exist, the change will result in an IllegalArgumentException.
fieldNames - field names of the column to updatenewDataType - the new data typestatic TableChange updateColumnType(String[] fieldNames, DataType newDataType, boolean isNullable)
The field names are used to find the field to update.
If the field does not exist, the change will result in an IllegalArgumentException.
fieldNames - field names of the column to updatenewDataType - the new data typestatic TableChange updateColumnComment(String[] fieldNames, String newComment)
The name is used to find the field to update.
If the field does not exist, the change will result in an IllegalArgumentException.
fieldNames - field names of the column to updatenewComment - the new commentstatic TableChange deleteColumn(String[] fieldNames)
If the field does not exist, the change will result in an IllegalArgumentException.
fieldNames - field names of the column to delete