Skip to content

Commit 58620f6

Browse files
authored
[doc] Improve the Changelog Generation section of the PrimaryKey Table page (#1189)
1 parent ff4b120 commit 58620f6

File tree

1 file changed

+26
-6
lines changed
  • website/docs/table-design/table-types/pk-table

1 file changed

+26
-6
lines changed

website/docs/table-design/table-types/pk-table/index.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,33 @@ CREATE TABLE T
123123

124124
If the data written to the primary-key table is
125125
sequentially `+I(1, 2.0, 'apple')`, `+I(1, 4.0, 'banana')`, `-D(1, 4.0, 'banana')`, then the following change data will
126-
be generated.
126+
be generated. For example, the following Flink SQL statements illustrate this behavior:
127127

128-
```text
129-
+I(1, 2.0, 'apple')
130-
-U(1, 2.0, 'apple')
131-
+U(1, 4.0, 'banana')
132-
-D(1, 4.0, 'banana')
128+
```sql title="Flink SQL"
129+
-- set to batch mode to execute DELETE and INSERT statements
130+
SET execution.runtime-mode = batch;
131+
132+
-- insert to records with the same primary key k=1
133+
INSERT INTO T (k, v1) VALUES (1, 2.0,'apple');
134+
INSERT INTO T (k, v1) VALUES (1, 4.0,'banana');
135+
136+
-- delete the record with primary key k=1
137+
DELETE FROM T WHERE k = 1;
138+
139+
-- set to streaming mode to observe the changelogs
140+
SET execution.runtime-mode = streaming;
141+
SELECT * FROM T;
142+
```
143+
144+
Generate the following output in the Flink SQL CLI:
145+
146+
```
147+
| op | k | v1 | v2 |
148+
| ---- | ---- | ---- | ------ |
149+
| +I | 1 | 2.0 | apple |
150+
| -U | 1 | 2.0 | apple |
151+
| +U | 1 | 4.0 | banana |
152+
| -D | 1 | 4.0 | banana |
133153
```
134154

135155
## Data Queries

0 commit comments

Comments
 (0)