ilyasahsan123 commented on code in PR #41331:
URL: https://github.com/apache/beam/pull/41331#discussion_r4682637728


##########
sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/SourceRecordJson.java:
##########
@@ -584,6 +666,98 @@ public DataCollection(@Nullable String dataCollection, 
@Nullable Long eventCount
     }
   }
 
+  /** Depicts a schema change SourceRecord as a ChangeSchemaEvent to be mapped 
as JSON. */
+  @SuppressWarnings("unused") // Unused params are validated as JSON
+  static class ChangeSchemaEvent implements Serializable {
+
+    private final @Nullable String databaseName;
+    private final @Nullable String schemaName;
+    private final @Nullable String ddl;
+
+    @SerializedName("ts_ms")
+    private final @Nullable Long tsMs;
+
+    private final @Nullable List<TableChange> tableChanges;
+
+    /**
+     * ChangeSchemaEvent Initializer.
+     *
+     * @param databaseName Database the DDL statement was applied to
+     * @param schemaName Schema the DDL statement was applied to, null for 
MySQL
+     * @param ddl DDL statement that changed the schema
+     * @param tsMs Time the connector processed the event, in milliseconds
+     * @param tableChanges Tables created, altered or dropped by the DDL 
statement
+     */
+    public ChangeSchemaEvent(
+        @Nullable String databaseName,
+        @Nullable String schemaName,
+        @Nullable String ddl,
+        @Nullable Long tsMs,
+        @Nullable List<TableChange> tableChanges) {
+      this.databaseName = databaseName;
+      this.schemaName = schemaName;
+      this.ddl = ddl;
+      this.tsMs = tsMs;
+      this.tableChanges = tableChanges;
+    }
+
+    /**
+     * Transforms the ChangeSchemaEvent to a JSON string.
+     *
+     * @return JSON String
+     */
+    public String toJson() {
+      return GSON.toJson(this);
+    }
+
+    /** Depicts an entry of the tableChanges field within SourceRecord. */
+    static class TableChange implements Serializable {
+      private final @Nullable String type;
+      private final @Nullable String id;
+      private final @Nullable Table table;
+
+      /**
+       * TableChange Initializer.
+       *
+       * @param type Kind of change: {@code CREATE}, {@code ALTER} or {@code 
DROP}
+       * @param id Fully qualified table id, for example {@code 
"inventory"."customers"}
+       * @param table Table definition after the change

Review Comment:
   Valid point! I've adjusted the Javadoc for the `TableChange` constructor



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to