@Evolving
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 class |
TableChange.After
Column position AFTER means the specified column should be put after the given `column`.
|
static interface |
TableChange.ColumnChange |
static interface |
TableChange.ColumnPosition |
static class |
TableChange.DeleteColumn
A TableChange to delete a field.
|
static class |
TableChange.First
Column position FIRST means the specified column should be the first column.
|
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.UpdateColumnDefaultValue
A TableChange to update the default value of a field.
|
static class |
TableChange.UpdateColumnNullability
A TableChange to update the nullability of a field.
|
static class |
TableChange.UpdateColumnPosition
A TableChange to update the position 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 |
addColumn(String[] fieldNames,
DataType dataType,
boolean isNullable,
String comment,
TableChange.ColumnPosition position,
ColumnDefaultValue defaultValue)
Create a TableChange for adding a column.
|
static TableChange |
deleteColumn(String[] fieldNames,
Boolean ifExists)
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 |
updateColumnDefaultValue(String[] fieldNames,
String newDefaultValue)
Create a TableChange for updating the default value of a field.
|
static TableChange |
updateColumnNullability(String[] fieldNames,
boolean nullable)
Create a TableChange for updating the nullability of a field.
|
static TableChange |
updateColumnPosition(String[] fieldNames,
TableChange.ColumnPosition newPosition)
Create a TableChange for updating the position 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 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 addColumn(String[] fieldNames, DataType dataType, boolean isNullable, String comment, TableChange.ColumnPosition position, ColumnDefaultValue defaultValue)
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 stringposition
- the new columns's positiondefaultValue
- default value to return when scanning from the new column, if anystatic 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 updateColumnNullability(String[] fieldNames, boolean nullable)
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 updatenullable
- the nullabilitystatic 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 updateColumnPosition(String[] fieldNames, TableChange.ColumnPosition newPosition)
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 updatenewPosition
- the new positionstatic TableChange updateColumnDefaultValue(String[] fieldNames, String newDefaultValue)
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 updatenewDefaultValue
- the new default value SQL string (Spark SQL dialect).static TableChange deleteColumn(String[] fieldNames, Boolean ifExists)
If the field does not exist, the change will result in an IllegalArgumentException
.
fieldNames
- field names of the column to deleteifExists
- silence the error if column doesn't exist during drop