Class SchemaChangeProvider


  • public class SchemaChangeProvider
    extends Object
    The SchemaChangeProvider class provides static methods to create SchemaChange objects that represent different types of schema modifications.
    • Constructor Detail

      • SchemaChangeProvider

        public SchemaChangeProvider()
    • 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.