Class SchemaChangeEvent

java.lang.Object
io.debezium.schema.SchemaChangeEvent

public class SchemaChangeEvent extends Object
Represents a structural change to a database schema.
Author:
Gunnar Morling
  • Field Details

    • database

      private final String database
    • schema

      private final String schema
    • ddl

      private final String ddl
    • tables

      private final Set<Table> tables
    • type

    • partition

      private final Map<String,?> partition
    • offset

      private final Map<String,?> offset
    • source

      private final org.apache.kafka.connect.data.Struct source
    • isFromSnapshot

      private final boolean isFromSnapshot
    • timestamp

      private final Instant timestamp
    • tableChanges

      private TableChanges tableChanges
  • Constructor Details

  • Method Details

    • getPartition

      public Map<String,?> getPartition()
    • getOffset

      public Map<String,?> getOffset()
    • getSource

      public org.apache.kafka.connect.data.Struct getSource()
    • getDatabase

      public String getDatabase()
    • getSchema

      public String getSchema()
    • getDdl

      public String getDdl()
    • getTables

      public Set<Table> getTables()
    • getType

    • isFromSnapshot

      public boolean isFromSnapshot()
    • getTimestamp

      public Instant getTimestamp()
    • getTableChanges

      public TableChanges getTableChanges()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • of

      public static SchemaChangeEvent of(SchemaChangeEvent.SchemaChangeEventType type, Partition partition, OffsetContext offsetContext, String databaseName, String schemaName, String ddl, Table table, boolean isFromSnapshot)
      Create a schema change event for any event type that does not involve a table rename.
      Parameters:
      type - the schema change event type
      partition - the partition
      offsetContext - the offset context
      databaseName - the database name
      schemaName - the schema name
      ddl - the schema change DDL statement
      table - the affected relational table
      isFromSnapshot - flag indicating whether the change is from snapshot
      Returns:
      the schema change event
    • ofTableChange

      public static SchemaChangeEvent ofTableChange(TableChanges.TableChange change, Map<String,?> partition, Map<String,?> offset, org.apache.kafka.connect.data.Struct source, String databaseName, String schemaName)
      Create a schema change event for a TableChanges.TableChange.
      Parameters:
      change - the table change event
      partition - the partition
      offset - the offsets
      source - the source
      databaseName - the database name
      schemaName - the schema name
      Returns:
      the schema change event
    • ofDatabase

      public static SchemaChangeEvent ofDatabase(Partition partition, OffsetContext offsetContext, String databaseName, String ddl, boolean isFromSnapshot)
      Create a schema change event for a database-specific DDL operation.
      Parameters:
      partition - the partition
      offsetContext - the offset context
      databaseName - the database name
      ddl - the schema change DDL statement
      isFromSnapshot - flag indicating whether the change is from snapshot
      Returns:
      the schema change event
    • ofSnapshotCreate

      public static SchemaChangeEvent ofSnapshotCreate(Partition partition, OffsetContext offsetContext, String databaseName, Table table)
      Create a schema change event for a CREATE TABLE statement without DDL from snapshot phase.
      Parameters:
      partition - the partition
      offsetContext - the offset context
      databaseName - the database name
      table - the affected relational table
      Returns:
      the schema change event
    • ofCreate

      public static SchemaChangeEvent ofCreate(Partition partition, OffsetContext offsetContext, String databaseName, String schemaName, String ddl, Table table, boolean isFromSnapshot)
      Create a schema change event for a CREATE TABLE statement with DDL.
      Parameters:
      partition - the partition
      offsetContext - the offset context
      databaseName - the database name
      schemaName - the schema name
      ddl - the schema change DDL statement
      table - the affected relational table
      isFromSnapshot - flag indicating whether the change is from snapshot
      Returns:
      the schema change event
    • ofAlter

      public static SchemaChangeEvent ofAlter(Partition partition, OffsetContext offsetContext, String databaseName, String schemaName, String ddl, Table table)
      Create a schema change event for a ALTER TABLE event.
      Parameters:
      partition - the partition
      offsetContext - the offset context
      databaseName - the database name
      schemaName - the schema name
      ddl - the schema change DDL statement
      table - the affected relational table
      Returns:
      the schema change event
    • ofRename

      public static SchemaChangeEvent ofRename(Partition partition, OffsetContext offsetContext, String databaseName, String schemaName, String ddl, Table table, TableId previousTableId)
      Create a schema change event for a ALTER TABLE RENAME event.
      Parameters:
      partition - the partition
      offsetContext - the offset context
      databaseName - the database name
      schemaName - the schema name
      ddl - the schema change DDL statement
      table - the affected relational table
      previousTableId - the old, previous relational table identifier
      Returns:
      the schema change event
    • ofDrop

      public static SchemaChangeEvent ofDrop(Partition partition, OffsetContext offsetContext, String databaseName, String schemaName, String ddl, Table table)
      Create a schema change event for a DROP TABLE event.
      Parameters:
      partition - the partition
      offsetContext - the offset context
      databaseName - the database name
      schemaName - the schema name
      ddl - the schema change DDL statement
      table - the affected relational table
      Returns:
      the schema change event
    • toSchemaChangeEventType

      private static SchemaChangeEvent.SchemaChangeEventType toSchemaChangeEventType(TableChanges.TableChangeType type)