Class SchemaChangeProvider
- java.lang.Object
-
- org.apache.flink.cdc.connectors.paimon.sink.SchemaChangeProvider
-
public class SchemaChangeProvider extends Object
The SchemaChangeProvider class provides static methods to create SchemaChange objects that represent different types of schema modifications.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_DATETIMEstatic StringINVALID_OR_MISSING_DATATIME
-
Constructor Summary
Constructors Constructor Description SchemaChangeProvider()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<org.apache.paimon.schema.SchemaChange>add(AddColumnEvent.ColumnWithPosition columnWithPosition)Creates a SchemaChange object for adding a column without specifying its position.static List<org.apache.paimon.schema.SchemaChange>add(AddColumnEvent.ColumnWithPosition columnWithPosition, Map<String,String> tableOptions)Creates a SchemaChange object for adding a column without specifying its position.static List<org.apache.paimon.schema.SchemaChange>add(AddColumnEvent.ColumnWithPosition columnWithPosition, org.apache.paimon.schema.SchemaChange.Move move)Creates a SchemaChange object for adding a column with a specified position.static List<org.apache.paimon.schema.SchemaChange>add(AddColumnEvent.ColumnWithPosition columnWithPosition, org.apache.paimon.schema.SchemaChange.Move move, Map<String,String> tableOptions)Creates a SchemaChange object for adding a column with a specified position.static org.apache.paimon.types.DataTypeconvertToBlobIfNeeded(Column column, Map<String,String> tableOptions)Convert CDC VARBINARY/BINARY/VARCHAR/STRING type to Paimon BLOB type if configured.static List<org.apache.paimon.schema.SchemaChange>drop(String columnName)Creates a SchemaChange object for dropping a column.static List<org.apache.paimon.schema.SchemaChange>rename(String oldColumnName, String newColumnName, Map<String,String> options)Creates a SchemaChange object for renaming a column.static org.apache.paimon.schema.SchemaChangesetOption(String key, String value)Creates a SchemaChange object for setting an option.static Optional<org.apache.paimon.schema.SchemaChange>updateColumnType(org.apache.paimon.schema.TableSchema tableSchema, String oldColumnName, DataType newType)Creates a SchemaChange object to update the data type of a column.static Optional<org.apache.paimon.schema.SchemaChange>updateColumnType(org.apache.paimon.schema.TableSchema tableSchema, String oldColumnName, DataType newType, Map<String,String> tableOptions)Creates a SchemaChange object to update the data type of a column.
-
-
-
Field Detail
-
DEFAULT_DATETIME
public static final String DEFAULT_DATETIME
- See Also:
- Constant Field Values
-
INVALID_OR_MISSING_DATATIME
public static final String INVALID_OR_MISSING_DATATIME
- See Also:
- Constant Field Values
-
-
Method Detail
-
add
public static List<org.apache.paimon.schema.SchemaChange> add(AddColumnEvent.ColumnWithPosition columnWithPosition)
Creates a SchemaChange object for adding a column without specifying its position.- Parameters:
columnWithPosition- The ColumnWithPosition object containing the column details and its intended position within the schema.- Returns:
- A SchemaChange object representing the addition of a column.
-
add
public static List<org.apache.paimon.schema.SchemaChange> add(AddColumnEvent.ColumnWithPosition columnWithPosition, Map<String,String> tableOptions)
Creates a SchemaChange object for adding a column without specifying its position. Supports converting VARBINARY/BINARY/VARCHAR/STRING to BLOB type based on tableOptions configuration.- Parameters:
columnWithPosition- The ColumnWithPosition object containing the column details.tableOptions- The table options containing blob-field configuration.- Returns:
- A SchemaChange object representing the addition of a column.
-
add
public static List<org.apache.paimon.schema.SchemaChange> add(AddColumnEvent.ColumnWithPosition columnWithPosition, org.apache.paimon.schema.SchemaChange.Move move)
Creates a SchemaChange object for adding a column with a specified position.- Parameters:
columnWithPosition- The ColumnWithPosition object containing the column details and its intended position within the schema.move- The move operation to indicate the column's new position.- Returns:
- A SchemaChange object representing the addition of a column with position information.
-
add
public static List<org.apache.paimon.schema.SchemaChange> add(AddColumnEvent.ColumnWithPosition columnWithPosition, org.apache.paimon.schema.SchemaChange.Move move, Map<String,String> tableOptions)
Creates a SchemaChange object for adding a column with a specified position. Supports converting VARBINARY/BINARY/VARCHAR/STRING to BLOB type based on tableOptions configuration.- Parameters:
columnWithPosition- The ColumnWithPosition object containing the column details.move- The move operation to indicate the column's new position.tableOptions- The table options containing blob-field configuration.- Returns:
- A SchemaChange object representing the addition of a column with position information.
-
convertToBlobIfNeeded
public static org.apache.paimon.types.DataType convertToBlobIfNeeded(Column column, Map<String,String> tableOptions)
Convert CDC VARBINARY/BINARY/VARCHAR/STRING type to Paimon BLOB type if configured.- Parameters:
column- The CDC column definition.tableOptions- The table options containing blob-field configuration.- Returns:
- The Paimon DataType (BLOB if configured, otherwise original converted type).
-
updateColumnType
public static Optional<org.apache.paimon.schema.SchemaChange> updateColumnType(org.apache.paimon.schema.TableSchema tableSchema, String oldColumnName, DataType newType)
Creates a SchemaChange object to update the data type of a column.- Parameters:
oldColumnName- The name of the column whose data type is to be updated.newType- The new DataType for the column.- Returns:
- A SchemaChange object representing the update of the column's data type.
-
updateColumnType
public static Optional<org.apache.paimon.schema.SchemaChange> updateColumnType(org.apache.paimon.schema.TableSchema tableSchema, String oldColumnName, DataType newType, Map<String,String> tableOptions)
Creates a SchemaChange object to update the data type of a column. Supports converting VARBINARY/BINARY/VARCHAR/STRING to BLOB type based on tableOptions configuration.- Parameters:
tableSchema- The TableSchema object containing the current schema of the table.oldColumnName- The name of the column whose data type is to be updated.newType- The new DataType for the column.tableOptions- The table options containing blob-field configuration.- Returns:
- An Optional of the SchemaChange that represents the update of the column's data type.
-
rename
public static List<org.apache.paimon.schema.SchemaChange> rename(String oldColumnName, String newColumnName, Map<String,String> options)
Creates a SchemaChange object for renaming a column.- Parameters:
oldColumnName- The current name of the column to be renamed.newColumnName- The new name for the column.- Returns:
- A SchemaChange object representing the renaming of a column.
-
drop
public static List<org.apache.paimon.schema.SchemaChange> drop(String columnName)
Creates a SchemaChange object for dropping a column.- Parameters:
columnName- The name of the column to be dropped.- Returns:
- A SchemaChange object representing the deletion of a column.
-
setOption
public static org.apache.paimon.schema.SchemaChange setOption(String key, String value)
Creates a SchemaChange object for setting an option.- Parameters:
key- The key of the option to be set.value- The value of the option to be set.- Returns:
- A SchemaChange object representing the setting of an option.
-
-