-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] CDC: Add example for message structure when transformers are used. #25469
Open
vaibhav-yb
wants to merge
12
commits into
yugabyte:master
Choose a base branch
from
vaibhav-yb:pgcompatible-smt-example
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+551
−54
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fa28c91
added example record structure for pgcompatible
vaibhav-yb 872a19d
added example
vaibhav-yb 46a4fda
Merge branch 'master' into pgcompatible-smt-example
vaibhav-yb ed2e3ee
added example
vaibhav-yb 4759bf0
fixed shortcode
vaibhav-yb a246cd8
committed to docs
vaibhav-yb d760bbf
resolved merge conflicts
vaibhav-yb bc718ef
edits
ddhodge 2bb3c51
added page to stable as well
vaibhav-yb a414220
menus
ddhodge 11d9a4b
format
ddhodge a25f616
Merge branch 'master' into pgcompatible-smt-example
ddhodge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
...t/preview/develop/change-data-capture/using-logical-replication/transformers.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
--- | ||
title: YugabyteDB connector transformers | ||
headerTitle: YugabyteDB connector transformers | ||
linkTitle: Connector transformers | ||
description: YugabyteDB connector transformers for Change Data Capture. | ||
menu: | ||
preview: | ||
parent: yugabytedb-connector | ||
identifier: yugabytedb-connector-transformers | ||
weight: 70 | ||
type: docs | ||
--- | ||
|
||
The YugabyteDB Connector comes bundled with Single Message Transformers (SMTs). SMTs are applied to messages as they flow through Kafka Connect so that sinks understand the format in which data is sent. SMTs transform inbound messages after a source connector has produced them, but before they are written to Kafka. SMTs transform outbound messages before they are sent to a sink connector. | ||
|
||
The following SMTs are bundled with the connector jar file available on [GitHub releases](https://github.com/yugabyte/debezium/releases): | ||
|
||
* YBExtractNewRecordState | ||
* PGCompatible | ||
|
||
{{< note title="Important" >}} | ||
|
||
These SMTs are only compatible with the [yboutput plugin](../key-concepts#output-plugin). | ||
ddhodge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
{{< /note >}} | ||
|
||
## Example | ||
|
||
For simplicity, only `before` and `after` fields of the `payload` of the message published by the connector are mentioned in the following examples. Any information pertaining to the record schema, if it is the same as the standard Debezium connector for PostgreSQL, is skipped. | ||
|
||
Consider a table created using the following statement: | ||
|
||
```sql | ||
CREATE TABLE test (id INT PRIMARY KEY, name TEXT, aura INT); | ||
``` | ||
|
||
The following DML statements will be used to demonstrate payload in case of individual replica identities: | ||
|
||
```sql | ||
-- statement 1 | ||
INSERT INTO test VALUES (1, 'Vaibhav', 9876); | ||
|
||
-- statement 2 | ||
UPDATE test SET aura = 9999 WHERE id = 1; | ||
|
||
-- statement 3 | ||
UPDATE test SET name = 'Vaibhav Kushwaha', aura = 10 WHERE id = 1; | ||
|
||
-- statement 4 | ||
UPDATE test SET aura = NULL WHERE id = 1; | ||
|
||
-- statement 5 | ||
DELETE FROM test WHERE id = 1; | ||
``` | ||
|
||
## PGCompatible | ||
|
||
**Transformer class:** `io.debezium.connector.postgresql.transforms.PGCompatible` | ||
|
||
By default, the YugabyteDB CDC service publishes events with a schema that only includes columns that have been modified. The source connector then sends the value as `null` for columns that are missing in the payload. Each column payload includes a `set` field that is used to signal if a column has been set to `null` because it wasn't present in the payload from YugabyteDB. | ||
|
||
However, some sink connectors may not understand this format. PGCompatible transforms the payload to a format that is compatible with the format of standard change data events. Specifically, it transforms column schema and value to remove the `set` field and collapse the payload such that it only contains the data type schema and value. | ||
|
||
PGCompatible differs from YBExtractNewRecordState by recursively modifying all the fields in a payload. | ||
|
||
The following examples show what the payload would look like for each [replica identity](../key-concepts/#replica-identity). | ||
|
||
### CHANGE | ||
|
||
```output | ||
-- statement 1 | ||
"before":null,"after":{"id":1,"name":"Vaibhav","aura":9876} | ||
|
||
-- statement 2 | ||
"before":null,"after":{"id":1,"name":null,"aura":9999} | ||
|
||
-- statement 3 | ||
"before":null,"after":{"id":1,"name":"Vaibhav Kushwaha","aura":10} | ||
|
||
-- statement 4 | ||
"before":null,"after":{"id":1,"name":null,"aura":null} | ||
|
||
-- statement 5 | ||
"before":{"id":1,"name":null,"aura":null},"after":null | ||
``` | ||
|
||
Note that for statement 2 and 4, the columns that were not updated as a part of the UPDATE statement are `null` in the output field. | ||
|
||
### DEFAULT | ||
|
||
```output | ||
-- statement 1 | ||
"before":null,"after":{"id":1,"name":"Vaibhav","aura":9876} | ||
|
||
-- statement 2 | ||
"before":null,"after":{"id":1,"name":"Vaibhav","aura":9999} | ||
|
||
-- statement 3 | ||
"before":null,"after":{"id":1,"name":"Vaibhav Kushwaha","aura":10} | ||
|
||
-- statement 4 | ||
"before":null,"after":{"id":1,"name":"Vaibhav Kushwaha","aura":null} | ||
|
||
-- statement 5 | ||
"before":{"id":1,"name":null,"aura":null},"after":null | ||
``` | ||
|
||
### FULL | ||
|
||
```output | ||
-- statement 1 | ||
"before":null,"after":{"id":1,"name":"Vaibhav","aura":9876} | ||
|
||
-- statement 2 | ||
"before":{"id":1,"name":"Vaibhav","aura":9876},"after":{"id":1,"name":"Vaibhav","aura":9999} | ||
|
||
-- statement 3 | ||
"before":{"id":1,"name":"Vaibhav","aura":9999},"after":{"id":1,"name":"Vaibhav Kushwaha","aura":10} | ||
|
||
-- statement 4 | ||
"before":{"id":1,"name":"Vaibhav Kushwaha","aura":10},"after":{"id":1,"name":"Vaibhav Kushwaha","aura":null} | ||
|
||
-- statement 5 | ||
"before":{"id":1,"name":"Vaibhav Kushwaha","aura":null},"after":null | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
output is all on one line, which doesn't look great