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: docs/nightly/en/reference/sql/compatibility.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ GreptimeDB supports a subset of ANSI SQL and has some unique extensions. Some ma
9
9
2. Insert data: Consistent with ANSI SQL syntax, but requires the `TIME INDEX` column value (or default value) to be provided.
10
10
3. Update data: Does not support `UPDATE` syntax, but if the primary key and `TIME INDEX` corresponding column values are the same during `INSERT`, subsequent inserted rows will overwrite previously written rows, effectively achieving an update.
11
11
* Since 0.8, GreptimeDB supports [append mode](/reference/sql/create#create-an-append-only-table) that creates an append-only table with `append_mode="true"` option which keeps duplicate rows.
12
+
* GreptimeDB supports [merge mode](/reference/sql/create#create-an-append-only-table) that creates a table with `merge_mode="last_non_null"` option which allow updating a field partially.
12
13
4. Query data: Query syntax is compatible with ANSI SQL, with some functional differences and omissions.
13
14
* Does not support views.
14
15
* TQL syntax extension: Supports executing PromQL in SQL via TQL subcommands. Please refer to the [TQL](./tql.md) section for details.
Copy file name to clipboardExpand all lines: docs/nightly/en/reference/sql/create.md
+63-1Lines changed: 63 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -98,7 +98,8 @@ Users can add table options by using `WITH`. The valid options contain the follo
98
98
|`compaction.twcs.max_inactive_window_files`| Max num of files that can be kept in inactive time window. | String value, such as '1'. Only available when `compaction.type` is `twcs`. |
99
99
|`compaction.twcs.time_window`| Compaction time window | String value, such as '1d' for 1 day. The table usually partitions rows into different time windows by their timestamps. Only available when `compaction.type` is `twcs`. |
100
100
|`memtable.type`| Type of the memtable. | String value, supports `time_series`, `partition_tree`. |
101
-
|`append_mode`| Whether the table is append-only | String value. Default is 'false', which removes duplicate rows by primary keys and timestamps. Setting it to 'true' to enable append mode and create an append-only table which keeps duplicate rows. |
101
+
|`append_mode`| Whether the table is append-only | String value. Default is 'false', which removes duplicate rows by primary keys and timestamps according to the `merge_mode`. Setting it to 'true' to enable append mode and create an append-only table which keeps duplicate rows. |
102
+
|`merge_mode`| The strategy to merge duplicate rows | String value. Only available when `append_mode` is 'false'. Default is `last_row`, which keeps the last row for the same primary key and timestamp. Setting it to `last_non_null` to keep the last non-null field for the same primary key and timestamp. |
102
103
|`comment`| Table level comment | String value. |
103
104
104
105
#### Create a table with TTL
@@ -149,6 +150,67 @@ CREATE TABLE IF NOT EXISTS temperatures(
149
150
) engine=mito with('append_mode'='true');
150
151
```
151
152
153
+
#### Create a table with merge mode
154
+
Create a table with `last_row` merge mode, which is the default merge mode.
155
+
```sql
156
+
createtableif not exists metrics(
157
+
host string,
158
+
ts timestamp,
159
+
cpu double,
160
+
memory double,
161
+
TIME INDEX (ts),
162
+
PRIMARY KEY(host)
163
+
)
164
+
engine=mito
165
+
with('merge_mode'='last_row');
166
+
```
167
+
168
+
Under `last_row` mode, the table merges rows with the same primary key and timestamp by only keeping the latest row.
0 commit comments