Package io.debezium.schema
Class SchemaChangeEvent
java.lang.Object
io.debezium.schema.SchemaChangeEvent
Represents a structural change to a database schema.
- Author:
- Gunnar Morling
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Type describing the content of the event. -
Field Summary
Modifier and TypeFieldDescriptionprivate final String
private final String
private final boolean
private final String
private final org.apache.kafka.connect.data.Struct
private TableChanges
private final Instant
private final SchemaChangeEvent.SchemaChangeEventType
-
Constructor Summary
ModifierConstructorDescriptionprivate
SchemaChangeEvent
(Map<String, ?> partition, Map<String, ?> offset, org.apache.kafka.connect.data.Struct source, String database, String schema, String ddl, Table table, SchemaChangeEvent.SchemaChangeEventType type, boolean isFromSnapshot, TableId previousTableId) private
SchemaChangeEvent
(Map<String, ?> partition, Map<String, ?> offset, org.apache.kafka.connect.data.Struct source, String database, String schema, String ddl, Set<Table> tables, SchemaChangeEvent.SchemaChangeEventType type, boolean isFromSnapshot, Instant timestamp, TableId previousTableId) -
Method Summary
Modifier and TypeMethodDescriptiongetDdl()
org.apache.kafka.connect.data.Struct
getType()
boolean
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.static SchemaChangeEvent
ofAlter
(Partition partition, OffsetContext offsetContext, String databaseName, String schemaName, String ddl, Table table) Create a schema change event for aALTER TABLE
event.static SchemaChangeEvent
ofCreate
(Partition partition, OffsetContext offsetContext, String databaseName, String schemaName, String ddl, Table table, boolean isFromSnapshot) Create a schema change event for aCREATE TABLE
statement with DDL.static SchemaChangeEvent
ofDatabase
(Partition partition, OffsetContext offsetContext, String databaseName, String ddl, boolean isFromSnapshot) Create a schema change event for a database-specific DDL operation.static SchemaChangeEvent
ofDrop
(Partition partition, OffsetContext offsetContext, String databaseName, String schemaName, String ddl, Table table) Create a schema change event for aDROP TABLE
event.static SchemaChangeEvent
ofRename
(Partition partition, OffsetContext offsetContext, String databaseName, String schemaName, String ddl, Table table, TableId previousTableId) Create a schema change event for aALTER TABLE RENAME
event.static SchemaChangeEvent
ofSnapshotCreate
(Partition partition, OffsetContext offsetContext, String databaseName, Table table) Create a schema change event for aCREATE TABLE
statement without DDL from snapshot phase.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 aTableChanges.TableChange
.private static SchemaChangeEvent.SchemaChangeEventType
toString()
-
Field Details
-
database
-
schema
-
ddl
-
tables
-
type
-
partition
-
offset
-
source
private final org.apache.kafka.connect.data.Struct source -
isFromSnapshot
private final boolean isFromSnapshot -
timestamp
-
tableChanges
-
-
Constructor Details
-
SchemaChangeEvent
-
SchemaChangeEvent
-
-
Method Details
-
getPartition
-
getOffset
-
getSource
public org.apache.kafka.connect.data.Struct getSource() -
getDatabase
-
getSchema
-
getDdl
-
getTables
-
getType
-
isFromSnapshot
public boolean isFromSnapshot() -
getTimestamp
-
getTableChanges
-
toString
-
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 typepartition
- the partitionoffsetContext
- the offset contextdatabaseName
- the database nameschemaName
- the schema nameddl
- the schema change DDL statementtable
- the affected relational tableisFromSnapshot
- 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 aTableChanges.TableChange
.- Parameters:
change
- the table change eventpartition
- the partitionoffset
- the offsetssource
- the sourcedatabaseName
- the database nameschemaName
- 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 partitionoffsetContext
- the offset contextdatabaseName
- the database nameddl
- the schema change DDL statementisFromSnapshot
- 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 aCREATE TABLE
statement without DDL from snapshot phase.- Parameters:
partition
- the partitionoffsetContext
- the offset contextdatabaseName
- the database nametable
- 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 aCREATE TABLE
statement with DDL.- Parameters:
partition
- the partitionoffsetContext
- the offset contextdatabaseName
- the database nameschemaName
- the schema nameddl
- the schema change DDL statementtable
- the affected relational tableisFromSnapshot
- 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 aALTER TABLE
event.- Parameters:
partition
- the partitionoffsetContext
- the offset contextdatabaseName
- the database nameschemaName
- the schema nameddl
- the schema change DDL statementtable
- 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 aALTER TABLE RENAME
event.- Parameters:
partition
- the partitionoffsetContext
- the offset contextdatabaseName
- the database nameschemaName
- the schema nameddl
- the schema change DDL statementtable
- the affected relational tablepreviousTableId
- 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 aDROP TABLE
event.- Parameters:
partition
- the partitionoffsetContext
- the offset contextdatabaseName
- the database nameschemaName
- the schema nameddl
- the schema change DDL statementtable
- the affected relational table- Returns:
- the schema change event
-
toSchemaChangeEventType
private static SchemaChangeEvent.SchemaChangeEventType toSchemaChangeEventType(TableChanges.TableChangeType type)
-