Skip to content

Commit f26743c

Browse files
committed
fixed doc
1 parent a4408d2 commit f26743c

File tree

1 file changed

+22
-18
lines changed
  • website/docs/table-design/table-types/pk-table/merge-engines

1 file changed

+22
-18
lines changed

website/docs/table-design/table-types/pk-table/merge-engines/versioned.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ sidebar_position: 3
55

66
# Versioned Merge Engine
77

8-
By specifying `'table.merge-engine' = 'versioned'`, users can update data based on the configured version column. Updates will be carried out when the latest value of the specified field is greater than the stored value. If it is less than or empty, no update will be made.
8+
By setting `'table.merge-engine' = 'versioned'`, users can update data based on the configured version column. Updates will be carried out when the latest value of the specified field is greater than or equal to the stored value. If it is less than or null, no update will be made.
9+
This feature is particularly valuable for replacing [Deduplication](https://nightlies.apache.org/flink/flink-docs-release-1.20/docs/dev/table/sql/queries/deduplication/) transformations in streaming computations, reducing complexity and improving overall efficiency.
910

1011
:::note
1112
When using `versioned` merge engine, there are the following limits:
12-
- `UPDATE` and `DELETE` statements are not supported
13-
- Partial update is not supported
14-
:::
13+
- `UPDATE` and `DELETE` statements are not supported.
14+
- Partial update is not supported.
15+
- `UPDATE_BEFORE` and `DELETE` changelog events are ignored automatically.
16+
:::
1517

1618
## Versioned Merge Column
1719

@@ -23,24 +25,24 @@ The versioned merge column supports the following data types.
2325
- TIMESTAMP(p)
2426
- TIMESTAMP_LTZ
2527
- TIMESTAMP_LTZ(p)
26-
:::
28+
:::
2729

2830
example:
29-
```sql title="versioned"
31+
```sql title="Flink SQL"
3032

31-
create table merge_engine_with_version (
32-
a int not null primary key not enforced,
33-
b string,
34-
ts bigint
35-
) with(
33+
CREATE TABLE VERSIONED (
34+
a INT NOT NULL PRIMARY KEY NOT ENFORCED,
35+
b STRING,
36+
ts BIGINT
37+
) WITH (
3638
'table.merge-engine' = 'versioned',
3739
'table.merge-engine.versioned.ver-column' = 'ts'
3840
);
39-
insert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v1', 1000);
41+
INSERT INTO VERSIONED (a, b, ts) VALUES (1, 'v1', 1000);
4042

4143
-- insert data with ts < 1000, no update will be made
42-
insert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v2', 999);
43-
select * from merge_engine_with_version;
44+
INSERT INTO VERSIONED (a, b, ts) VALUES (1, 'v2', 999);
45+
SELECT * FROM VERSIONED;
4446
-- Output
4547
-- +---+-----+------+
4648
-- | a | b | ts |
@@ -50,21 +52,23 @@ select * from merge_engine_with_version;
5052

5153

5254
-- insert data with ts > 1000, update will be made
53-
insert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v2', 2000);
54-
select * from merge_engine_with_version;
55+
INSERT INTO VERSIONED (a, b, ts) VALUES (1, 'v2', 2000);
56+
SELECT * FROM VERSIONED;
5557
-- Output
5658
-- +---+-----+------+
5759
-- | a | b | ts |
5860
-- +---+-----+------+
5961
-- | 1 | v2 | 2000 |
62+
-- +---+-----+------+
6063

6164
-- insert data with ts = null, no update will be made
62-
nsert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v2', null);
63-
select * from merge_engine_with_version;
65+
INSERT INTO VERSIONED (a, b, ts) VALUES (1, 'v2', null);
66+
SELECT * FROM VERSIONED;
6467
-- Output
6568
-- +---+-----+------+
6669
-- | a | b | ts |
6770
-- +---+-----+------+
6871
-- | 1 | v2 | 2000 |
72+
-- +---+-----+------+
6973

7074
```

0 commit comments

Comments
 (0)