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/reference/sql/create.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -499,10 +499,14 @@ CREATE [OR REPLACE] FLOW [ IF NOT EXISTS ] <flow-name>
499
499
SINK TO <sink-table-name>
500
500
[ EXPIRE AFTER <expr> ]
501
501
[ COMMENT '<string>' ]
502
+
[ WITH (<flow-option>=<value> [, ...]) ]
502
503
AS
503
504
<SQL>;
504
505
```
505
506
507
+
The `WITH` clause specifies flow options.
508
+
For example, the experimental `experimental_enable_incremental_read` option enables incremental source reads for eligible batching flows.
509
+
506
510
For `CREATE FLOW`, the query after `AS` can be a regular flow query or a TQL query. GreptimeDB also supports a strict TQL CTE form for cleaner flow definitions:
Copy file name to clipboardExpand all lines: docs/user-guide/flow-computation/manage-flow.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,7 @@ CREATE [ OR REPLACE ] FLOW [ IF NOT EXISTS ] <flow-name>
101
101
SINK TO <sink-table-name>
102
102
[ EXPIRE AFTER <expr> ]
103
103
[ COMMENT '<string>' ]
104
+
[ WITH (<flow-option>=<value> [, ...]) ]
104
105
AS
105
106
<SQL>;
106
107
```
@@ -117,6 +118,8 @@ Conversely, when `IF NOT EXISTS` is specified, the command will have no effect i
117
118
-`EXPIRE AFTER` is an optional interval to expire the data from the Flow engine.
118
119
For more details, please refer to the [`EXPIRE AFTER`](#expire-after) part.
119
120
-`COMMENT` is the description of the flow.
121
+
-`WITH` specifies flow options.
122
+
For example, the experimental `experimental_enable_incremental_read` option enables incremental source reads for eligible batching flows.
120
123
-`SQL` part defines the continuous aggregation query.
121
124
It defines the source tables provide data for the flow.
122
125
Each flow can have multiple source tables.
@@ -158,6 +161,53 @@ For example, if the flow engine processes the aggregation at 10:00:00 and the `'
158
161
any input data that arrive now with a time index older than 1 hour (before 09:00:00) will expire and be ignore.
159
162
Only data timestamped from 09:00:00 onwards will be used in the aggregation and update to sink table.
160
163
164
+
### Experimental incremental source reads
165
+
166
+
:::warning Experimental feature
167
+
The `experimental_enable_incremental_read` option is experimental.
168
+
Its behavior and limitations may change in future releases.
169
+
:::
170
+
171
+
For batching SQL flows whose source tables are append-only, you can enable incremental source reads:
172
+
173
+
```sql
174
+
CREATETABLEtemp_sensor_data (
175
+
sensor_id INT,
176
+
loc STRING,
177
+
temperature DOUBLE,
178
+
ts TIMESTAMPTIME INDEX,
179
+
PRIMARY KEY(sensor_id, loc)
180
+
) WITH ('append_mode'='true');
181
+
182
+
CREATE FLOW temp_monitoring
183
+
SINK TO temp_alerts
184
+
WITH (experimental_enable_incremental_read ='true')
185
+
AS
186
+
SELECT
187
+
sensor_id,
188
+
loc,
189
+
max(temperature) AS max_temp,
190
+
date_bin('10 seconds'::INTERVAL, ts) AS time_window
191
+
FROM temp_sensor_data
192
+
GROUP BY
193
+
sensor_id,
194
+
loc,
195
+
time_window;
196
+
```
197
+
198
+
When this option is enabled, Flow keeps per-region source sequence watermarks and attempts to read only newly appended source rows after the initial full snapshot.
199
+
This is an execution optimization and does not change the query result.
200
+
201
+
The current limitations are:
202
+
203
+
- All source tables must be append-only tables created with `append_mode = 'true'`.
204
+
Flow creation fails if any source table is not append-only.
205
+
- The optimization only applies to batching SQL flows.
206
+
TQL flows, unsupported aggregate shapes, and simple projection/filter flows do not use incremental source reads.
207
+
- Source tables created with `ttl = 'instant'` currently use streaming mode and do not use this batching-mode option.
208
+
- The first run still needs a full snapshot.
209
+
Later runs may fall back to full snapshot or retry/repair when GreptimeDB cannot safely use incremental source reads.
210
+
161
211
### Write a SQL query
162
212
163
213
The `SQL` part of the flow is similar to a standard `SELECT` clause with a few differences. The syntax of the query is as follows:
0 commit comments