You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/table-design/table-types/pk-table/merge-engines/versioned.md
+63-1Lines changed: 63 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,4 +5,66 @@ sidebar_position: 3
5
5
6
6
# Versioned Merge Engine
7
7
8
-
TODO: Fill me #459
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.
9
+
10
+
:::note
11
+
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
+
:::
15
+
16
+
## Versioned Merge Column
17
+
18
+
:::note
19
+
The versioned merge column supports the following data types.
20
+
- INT
21
+
- BIGINT
22
+
- TIMESTAMP
23
+
- TIMESTAMP(p)
24
+
- TIMESTAMP_LTZ
25
+
- TIMESTAMP_LTZ(p)
26
+
:::
27
+
28
+
example:
29
+
```sql title="versioned"
30
+
31
+
createtablemerge_engine_with_version (
32
+
a intnot nullprimary key not enforced,
33
+
b string,
34
+
ts bigint
35
+
) with(
36
+
'table.merge-engine'='versioned',
37
+
'table.merge-engine.versioned.ver-column'='ts'
38
+
);
39
+
insert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v1', 1000);
40
+
41
+
-- 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
+
-- Output
45
+
-- +---+-----+------+
46
+
-- | a | b | ts |
47
+
-- +---+-----+------+
48
+
-- | 1 | v1 | 1000 |
49
+
-- +---+-----+------+
50
+
51
+
52
+
-- 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
+
-- Output
56
+
-- +---+-----+------+
57
+
-- | a | b | ts |
58
+
-- +---+-----+------+
59
+
-- | 1 | v2 | 2000 |
60
+
61
+
-- insert data with ts = null, no update will be made
62
+
nsert into merge_engine_with_version ( a,b,ts ) VALUES (1, 'v2', null);
0 commit comments