Skip to content

Commit 9b26225

Browse files
authored
fix: quote in flow docs (#1989)
1 parent b26d579 commit 9b26225

File tree

4 files changed

+132
-136
lines changed

4 files changed

+132
-136
lines changed

docs/user-guide/flow-computation/continuous-aggregation.md

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ CREATE TABLE `ngx_statistics` (
6262
);
6363
```
6464

65-
Then create the flow `ngx_aggregation` to aggregate a series of aggregate functions, including `count`, `min`, `max`, `avg` of the `size` column, and the sum of all packets of size great than 550. The aggregation is calculated in 1-minute fixed windows of `access_time` column and also grouped by the `status` column. So you can be made aware in real time the information about packet size and action upon it, i.e. if the `high_size_count` became too high at a certain point, you can further examine if anything goes wrong, or if the `max_size` column suddenly spike in a 1 minute time window, you can then trying to locate that packet and further inspect it.
65+
Then create the flow `ngx_aggregation` to aggregate a series of aggregate functions, including `count`, `min`, `max`, `avg` of the `size` column, and the sum of all packets of size great than 550. The aggregation is calculated in 1-minute fixed windows of `access_time` column and also grouped by the `status` column. So you can be made aware in real time the information about packet size and action upon it, i.e. if the `high_size_count` became too high at a certain point, you can further examine if anything goes wrong, or if the `max_size` column suddenly spike in a 1 minute time window, you can then trying to locate that packet and further inspect it.
6666

6767
The `EXPIRE AFTER '6h'` in the following SQL ensures that the flow computation only uses source data from the last 6 hours. Data older than 6 hours in the sink table will not be modified by this flow. For more details, see [manage-flow](manage-flow.md#expire-after).
6868

@@ -89,12 +89,12 @@ GROUP BY
8989
To observe the outcome of the continuous aggregation in the `ngx_statistics` table, insert some data into the source table `ngx_access_log`.
9090

9191
```sql
92-
INSERT INTO ngx_access_log
92+
INSERT INTO ngx_access_log
9393
VALUES
94-
("android", "Android", "referer", "GET", "/api/v1", "trace_id", "HTTP", 200, 1000, "agent", now() - INTERVAL '1' minute),
95-
("ios", "iOS", "referer", "GET", "/api/v1", "trace_id", "HTTP", 200, 500, "agent", now() - INTERVAL '1' minute),
96-
("android", "Android", "referer", "GET", "/api/v1", "trace_id", "HTTP", 200, 600, "agent", now()),
97-
("ios", "iOS", "referer", "GET", "/api/v1", "trace_id", "HTTP", 404, 700, "agent", now());
94+
('android', 'Android', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 200, 1000, 'agent', now() - INTERVAL '1' minute),
95+
('ios', 'iOS', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 200, 500, 'agent', now() - INTERVAL '1' minute),
96+
('android', 'Android', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 200, 600, 'agent', now()),
97+
('ios', 'iOS', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 404, 700, 'agent', now());
9898
```
9999

100100
Then the sink table `ngx_statistics` will be incremental updated and contain the following data:
@@ -117,10 +117,10 @@ SELECT * FROM ngx_statistics;
117117
Try to insert more data into the `ngx_access_log` table:
118118

119119
```sql
120-
INSERT INTO ngx_access_log
120+
INSERT INTO ngx_access_log
121121
VALUES
122-
("android", "Android", "referer", "GET", "/api/v1", "trace_id", "HTTP", 200, 500, "agent", now()),
123-
("ios", "iOS", "referer", "GET", "/api/v1", "trace_id", "HTTP", 404, 800, "agent", now());
122+
('android', 'Android', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 200, 500, 'agent', now()),
123+
('ios', 'iOS', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 404, 800, 'agent', now());
124124
```
125125

126126
The sink table `ngx_statistics` now have corresponding rows updated, notes how `max_size`, `avg_size` and `high_size_count` are updated:
@@ -201,16 +201,16 @@ You can insert some data into the source table `ngx_access_log`:
201201

202202
```sql
203203
INSERT INTO ngx_access_log VALUES
204-
("client1", "US", now() - '2 hour'::INTERVAL),
205-
("client2", "US", now() - '2 hour'::INTERVAL),
206-
("client3", "UK", now() - '2 hour'::INTERVAL),
207-
("client4", "UK", now() - '1 hour'::INTERVAL),
208-
("client5", "CN", now() - '1 hour'::INTERVAL),
209-
("client6", "CN", now() - '1 hour'::INTERVAL),
210-
("client7", "JP", now()),
211-
("client8", "JP", now()),
212-
("client9", "KR", now()),
213-
("client10", "KR", now());
204+
('client1', 'US', now() - '2 hour'::INTERVAL),
205+
('client2', 'US', now() - '2 hour'::INTERVAL),
206+
('client3', 'UK', now() - '2 hour'::INTERVAL),
207+
('client4', 'UK', now() - '1 hour'::INTERVAL),
208+
('client5', 'CN', now() - '1 hour'::INTERVAL),
209+
('client6', 'CN', now() - '1 hour'::INTERVAL),
210+
('client7', 'JP', now()),
211+
('client8', 'JP', now()),
212+
('client9', 'KR', now()),
213+
('client10', 'KR', now());
214214
```
215215

216216
Wait for few seconds for the Flow to write the result to the sink table and then query:
@@ -288,8 +288,8 @@ Now that we have created the flow task, we can insert some data into the source
288288
```sql
289289

290290
INSERT INTO temp_sensor_data VALUES
291-
(1, "room1", 98.5, now() - '10 second'::INTERVAL),
292-
(2, "room2", 99.5, now());
291+
(1, 'room1', 98.5, now() - '10 second'::INTERVAL),
292+
(2, 'room2', 99.5, now());
293293
```
294294
table should be empty now, but still wait at least few seconds for flow to update results to sink table:
295295

@@ -305,8 +305,8 @@ Now insert some data that will trigger the alert:
305305

306306
```sql
307307
INSERT INTO temp_sensor_data VALUES
308-
(1, "room1", 101.5, now()),
309-
(2, "room2", 102.5, now());
308+
(1, 'room1', 101.5, now()),
309+
(2, 'room2', 102.5, now());
310310
```
311311

312312
wait at least few seconds for flow to update results to sink table:
@@ -350,7 +350,7 @@ CREATE TABLE ngx_distribution (
350350
PRIMARY KEY(stat, bucket_size)
351351
);
352352
/* create flow task to calculate the distribution of packet sizes for each status code */
353-
CREATE FLOW calc_ngx_distribution SINK TO ngx_distribution
353+
CREATE FLOW calc_ngx_distribution SINK TO ngx_distribution
354354
EXPIRE AFTER '6h'
355355
AS
356356
SELECT
@@ -376,16 +376,16 @@ Now that we have created the flow task, we can insert some data into the source
376376

377377
```sql
378378
INSERT INTO ngx_access_log VALUES
379-
("cli1", 200, 100, now()),
380-
("cli2", 200, 104, now()),
381-
("cli3", 200, 120, now()),
382-
("cli4", 200, 124, now()),
383-
("cli5", 200, 140, now()),
384-
("cli6", 404, 144, now()),
385-
("cli7", 404, 160, now()),
386-
("cli8", 404, 164, now()),
387-
("cli9", 404, 180, now()),
388-
("cli10", 404, 184, now());
379+
('cli1', 200, 100, now()),
380+
('cli2', 200, 104, now()),
381+
('cli3', 200, 120, now()),
382+
('cli4', 200, 124, now()),
383+
('cli5', 200, 140, now()),
384+
('cli6', 404, 144, now()),
385+
('cli7', 404, 160, now()),
386+
('cli8', 404, 164, now()),
387+
('cli9', 404, 180, now()),
388+
('cli10', 404, 184, now());
389389
```
390390
wait at least few seconds for flow to update results to sink table:
391391

@@ -411,4 +411,3 @@ SELECT * FROM ngx_distribution;
411411

412412
- [Manage Flow](manage-flow.md): Gain insights into the mechanisms of the Flow engine and the SQL syntax for defining a Flow.
413413
- [Expressions](expressions.md): Learn about the expressions supported by the Flow engine for data transformation.
414-

i18n/zh/docusaurus-plugin-content-docs/current/user-guide/flow-computation/continuous-aggregation.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ GROUP BY
8686
要检查持续聚合是否正常工作,首先插入一些数据到源表 `ngx_access_log` 中。
8787

8888
```sql
89-
INSERT INTO ngx_access_log
89+
INSERT INTO ngx_access_log
9090
VALUES
91-
("android", "Android", "referer", "GET", "/api/v1", "trace_id", "HTTP", 200, 1000, "agent", now() - INTERVAL '1' minute),
92-
("ios", "iOS", "referer", "GET", "/api/v1", "trace_id", "HTTP", 200, 500, "agent", now() - INTERVAL '1' minute),
93-
("android", "Android", "referer", "GET", "/api/v1", "trace_id", "HTTP", 200, 600, "agent", now()),
94-
("ios", "iOS", "referer", "GET", "/api/v1", "trace_id", "HTTP", 404, 700, "agent", now());
91+
('android', 'Android', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 200, 1000, 'agent', now() - INTERVAL '1' minute),
92+
('ios', 'iOS', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 200, 500, 'agent', now() - INTERVAL '1' minute),
93+
('android', 'Android', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 200, 600, 'agent', now()),
94+
('ios', 'iOS', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 404, 700, 'agent', now());
9595
```
9696

9797
`ngx_access_log` 表将被增量更新以包含以下数据:
@@ -116,8 +116,8 @@ SELECT * FROM ngx_statistics;
116116
```sql
117117
INSERT INTO ngx_access_log
118118
VALUES
119-
("android", "Android", "referer", "GET", "/api/v1", "trace_id", "HTTP", 200, 500, "agent", now()),
120-
("ios", "iOS", "referer", "GET", "/api/v1", "trace_id", "HTTP", 404, 800, "agent", now());
119+
('android', 'Android', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 200, 500, 'agent', now()),
120+
('ios', 'iOS', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 404, 800, 'agent', now());
121121
```
122122

123123
结果表 `ngx_statistics` 将被增量更新,注意 `max_size``avg_size``high_size_count` 是如何更新的:
@@ -195,16 +195,16 @@ GROUP BY
195195

196196
```sql
197197
INSERT INTO ngx_access_log VALUES
198-
("client1", "US", now() - '2 hour'::INTERVAL),
199-
("client2", "US", now() - '2 hour'::INTERVAL),
200-
("client3", "UK", now() - '2 hour'::INTERVAL),
201-
("client4", "UK", now() - '1 hour'::INTERVAL),
202-
("client5", "CN", now() - '1 hour'::INTERVAL),
203-
("client6", "CN", now() - '1 hour'::INTERVAL),
204-
("client7", "JP", now()),
205-
("client8", "JP", now()),
206-
("client9", "KR", now()),
207-
("client10", "KR", now());
198+
('client1', 'US', now() - '2 hour'::INTERVAL),
199+
('client2', 'US', now() - '2 hour'::INTERVAL),
200+
('client3', 'UK', now() - '2 hour'::INTERVAL),
201+
('client4', 'UK', now() - '1 hour'::INTERVAL),
202+
('client5', 'CN', now() - '1 hour'::INTERVAL),
203+
('client6', 'CN', now() - '1 hour'::INTERVAL),
204+
('client7', 'JP', now()),
205+
('client8', 'JP', now()),
206+
('client9', 'KR', now()),
207+
('client10', 'KR', now());
208208
```
209209

210210
等待几秒钟,让 flow 将结果写入 sink 表,然后查询:
@@ -279,8 +279,8 @@ HAVING max_temp > 100;
279279

280280
```sql
281281
INSERT INTO temp_sensor_data VALUES
282-
(1, "room1", 98.5, now() - '10 second'::INTERVAL),
283-
(2, "room2", 99.5, now());
282+
(1, 'room1', 98.5, now() - '10 second'::INTERVAL),
283+
(2, 'room2', 99.5, now());
284284
```
285285

286286
表现在应该是空的,等待几秒钟让 flow 将结果更新到输出表:
@@ -297,8 +297,8 @@ Empty set (0.00 sec)
297297

298298
```sql
299299
INSERT INTO temp_sensor_data VALUES
300-
(1, "room1", 101.5, now()),
301-
(2, "room2", 102.5, now());
300+
(1, 'room1', 101.5, now()),
301+
(2, 'room2', 102.5, now());
302302
```
303303

304304
等待几秒钟,让 flow 将结果更新到输出表:
@@ -340,7 +340,7 @@ CREATE TABLE ngx_distribution (
340340
PRIMARY KEY(stat, bucket_size)
341341
);
342342
/* 创建 flow 任务以计算每个状态码的包大小分布 */
343-
CREATE FLOW calc_ngx_distribution SINK TO ngx_distribution
343+
CREATE FLOW calc_ngx_distribution SINK TO ngx_distribution
344344
EXPIRE AFTER '6h'
345345
AS
346346
SELECT
@@ -366,16 +366,16 @@ GROUP BY
366366

367367
```sql
368368
INSERT INTO ngx_access_log VALUES
369-
("cli1", 200, 100, now()),
370-
("cli2", 200, 104, now()),
371-
("cli3", 200, 120, now()),
372-
("cli4", 200, 124, now()),
373-
("cli5", 200, 140, now()),
374-
("cli6", 404, 144, now()),
375-
("cli7", 404, 160, now()),
376-
("cli8", 404, 164, now()),
377-
("cli9", 404, 180, now()),
378-
("cli10", 404, 184, now());
369+
('cli1', 200, 100, now()),
370+
('cli2', 200, 104, now()),
371+
('cli3', 200, 120, now()),
372+
('cli4', 200, 124, now()),
373+
('cli5', 200, 140, now()),
374+
('cli6', 404, 144, now()),
375+
('cli7', 404, 160, now()),
376+
('cli8', 404, 164, now()),
377+
('cli9', 404, 180, now()),
378+
('cli10', 404, 184, now());
379379
```
380380

381381
等待几秒钟,让 flow 将结果更新到 sink 表:
@@ -402,4 +402,3 @@ SELECT * FROM ngx_distribution;
402402

403403
- [管理 Flow](manage-flow.md):深入了解 Flow 引擎的机制和定义 Flow 的 SQL 语法。
404404
- [表达式](expressions.md):了解 Flow 引擎支持的数据转换表达式。
405-

i18n/zh/docusaurus-plugin-content-docs/version-0.15/user-guide/flow-computation/continuous-aggregation.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ GROUP BY
8686
要检查持续聚合是否正常工作,首先插入一些数据到源表 `ngx_access_log` 中。
8787

8888
```sql
89-
INSERT INTO ngx_access_log
89+
INSERT INTO ngx_access_log
9090
VALUES
91-
("android", "Android", "referer", "GET", "/api/v1", "trace_id", "HTTP", 200, 1000, "agent", now() - INTERVAL '1' minute),
92-
("ios", "iOS", "referer", "GET", "/api/v1", "trace_id", "HTTP", 200, 500, "agent", now() - INTERVAL '1' minute),
93-
("android", "Android", "referer", "GET", "/api/v1", "trace_id", "HTTP", 200, 600, "agent", now()),
94-
("ios", "iOS", "referer", "GET", "/api/v1", "trace_id", "HTTP", 404, 700, "agent", now());
91+
('android', 'Android', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 200, 1000, 'agent', now() - INTERVAL '1' minute),
92+
('ios', 'iOS', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 200, 500, 'agent', now() - INTERVAL '1' minute),
93+
('android', 'Android', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 200, 600, 'agent', now()),
94+
('ios', 'iOS', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 404, 700, 'agent', now());
9595
```
9696

9797
`ngx_access_log` 表将被增量更新以包含以下数据:
@@ -116,8 +116,8 @@ SELECT * FROM ngx_statistics;
116116
```sql
117117
INSERT INTO ngx_access_log
118118
VALUES
119-
("android", "Android", "referer", "GET", "/api/v1", "trace_id", "HTTP", 200, 500, "agent", now()),
120-
("ios", "iOS", "referer", "GET", "/api/v1", "trace_id", "HTTP", 404, 800, "agent", now());
119+
('android', 'Android', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 200, 500, 'agent', now()),
120+
('ios', 'iOS', 'referer', 'GET', '/api/v1', 'trace_id', 'HTTP', 404, 800, 'agent', now());
121121
```
122122

123123
结果表 `ngx_statistics` 将被增量更新,注意 `max_size``avg_size``high_size_count` 是如何更新的:
@@ -195,16 +195,16 @@ GROUP BY
195195

196196
```sql
197197
INSERT INTO ngx_access_log VALUES
198-
("client1", "US", now() - '2 hour'::INTERVAL),
199-
("client2", "US", now() - '2 hour'::INTERVAL),
200-
("client3", "UK", now() - '2 hour'::INTERVAL),
201-
("client4", "UK", now() - '1 hour'::INTERVAL),
202-
("client5", "CN", now() - '1 hour'::INTERVAL),
203-
("client6", "CN", now() - '1 hour'::INTERVAL),
204-
("client7", "JP", now()),
205-
("client8", "JP", now()),
206-
("client9", "KR", now()),
207-
("client10", "KR", now());
198+
('client1', 'US', now() - '2 hour'::INTERVAL),
199+
('client2', 'US', now() - '2 hour'::INTERVAL),
200+
('client3', 'UK', now() - '2 hour'::INTERVAL),
201+
('client4', 'UK', now() - '1 hour'::INTERVAL),
202+
('client5', 'CN', now() - '1 hour'::INTERVAL),
203+
('client6', 'CN', now() - '1 hour'::INTERVAL),
204+
('client7', 'JP', now()),
205+
('client8', 'JP', now()),
206+
('client9', 'KR', now()),
207+
('client10', 'KR', now());
208208
```
209209

210210
等待几秒钟,让 flow 将结果写入 sink 表,然后查询:
@@ -279,8 +279,8 @@ HAVING max_temp > 100;
279279

280280
```sql
281281
INSERT INTO temp_sensor_data VALUES
282-
(1, "room1", 98.5, now() - '10 second'::INTERVAL),
283-
(2, "room2", 99.5, now());
282+
(1, 'room1', 98.5, now() - '10 second'::INTERVAL),
283+
(2, 'room2', 99.5, now());
284284
```
285285

286286
表现在应该是空的,等待几秒钟让 flow 将结果更新到输出表:
@@ -297,8 +297,8 @@ Empty set (0.00 sec)
297297

298298
```sql
299299
INSERT INTO temp_sensor_data VALUES
300-
(1, "room1", 101.5, now()),
301-
(2, "room2", 102.5, now());
300+
(1, 'room1', 101.5, now()),
301+
(2, 'room2', 102.5, now());
302302
```
303303

304304
等待几秒钟,让 flow 将结果更新到输出表:
@@ -340,7 +340,7 @@ CREATE TABLE ngx_distribution (
340340
PRIMARY KEY(stat, bucket_size)
341341
);
342342
/* 创建 flow 任务以计算每个状态码的包大小分布 */
343-
CREATE FLOW calc_ngx_distribution SINK TO ngx_distribution
343+
CREATE FLOW calc_ngx_distribution SINK TO ngx_distribution
344344
EXPIRE AFTER '6h'
345345
AS
346346
SELECT
@@ -366,16 +366,16 @@ GROUP BY
366366

367367
```sql
368368
INSERT INTO ngx_access_log VALUES
369-
("cli1", 200, 100, now()),
370-
("cli2", 200, 104, now()),
371-
("cli3", 200, 120, now()),
372-
("cli4", 200, 124, now()),
373-
("cli5", 200, 140, now()),
374-
("cli6", 404, 144, now()),
375-
("cli7", 404, 160, now()),
376-
("cli8", 404, 164, now()),
377-
("cli9", 404, 180, now()),
378-
("cli10", 404, 184, now());
369+
('cli1', 200, 100, now()),
370+
('cli2', 200, 104, now()),
371+
('cli3', 200, 120, now()),
372+
('cli4', 200, 124, now()),
373+
('cli5', 200, 140, now()),
374+
('cli6', 404, 144, now()),
375+
('cli7', 404, 160, now()),
376+
('cli8', 404, 164, now()),
377+
('cli9', 404, 180, now()),
378+
('cli10', 404, 184, now());
379379
```
380380

381381
等待几秒钟,让 flow 将结果更新到 sink 表:
@@ -402,4 +402,3 @@ SELECT * FROM ngx_distribution;
402402

403403
- [管理 Flow](manage-flow.md):深入了解 Flow 引擎的机制和定义 Flow 的 SQL 语法。
404404
- [表达式](expressions.md):了解 Flow 引擎支持的数据转换表达式。
405-

0 commit comments

Comments
 (0)