Skip to content

Commit 65f74e2

Browse files
authored
docs: add worker SQL reference (#3155)
* docs: add worker sql reference * docs: add chinese worker sql reference
1 parent 1e86a09 commit 65f74e2

14 files changed

Lines changed: 424 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "工作节点(Worker)",
3+
"position": 20
4+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: ALTER WORKER
3+
sidebar_position: 2
4+
---
5+
6+
修改 worker 的标签、选项或运行状态。
7+
8+
:::note
9+
此命令需要启用 cloud control。
10+
:::
11+
12+
## 语法
13+
14+
```sql
15+
ALTER WORKER <worker_name> SET TAG <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ]
16+
17+
ALTER WORKER <worker_name> UNSET TAG <tag_name> [ , <tag_name> , ... ]
18+
19+
ALTER WORKER <worker_name> SET <option_name> = '<option_value>' [ , <option_name> = '<option_value>' , ... ]
20+
21+
ALTER WORKER <worker_name> UNSET <option_name> [ , <option_name> , ... ]
22+
23+
ALTER WORKER <worker_name> SUSPEND
24+
25+
ALTER WORKER <worker_name> RESUME
26+
```
27+
28+
## 参数
29+
30+
| 形式 | 说明 |
31+
|------|-------------|
32+
| `SET TAG` | 添加或更新 worker 标签。 |
33+
| `UNSET TAG` | 删除一个或多个 worker 标签。 |
34+
| `SET` | 添加或更新 worker 选项。选项名会被规范化为小写。 |
35+
| `UNSET` | 删除一个或多个 worker 选项。 |
36+
| `SUSPEND` | 挂起 worker。 |
37+
| `RESUME` | 恢复 worker。 |
38+
39+
## 示例
40+
41+
为 worker 设置标签:
42+
43+
```sql
44+
ALTER WORKER ingest_worker
45+
SET TAG environment = 'prod', team = 'data-platform';
46+
```
47+
48+
更新 worker 选项:
49+
50+
```sql
51+
ALTER WORKER ingest_worker
52+
SET region = 'us-west-2', pool = 'streaming';
53+
```
54+
55+
删除标签和选项:
56+
57+
```sql
58+
ALTER WORKER ingest_worker UNSET TAG team;
59+
ALTER WORKER ingest_worker UNSET pool;
60+
```
61+
62+
修改 worker 状态:
63+
64+
```sql
65+
ALTER WORKER ingest_worker SUSPEND;
66+
ALTER WORKER ingest_worker RESUME;
67+
```
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: CREATE WORKER
3+
sidebar_position: 1
4+
---
5+
6+
创建一个 worker。
7+
8+
:::note
9+
此命令需要启用 cloud control。
10+
:::
11+
12+
## 语法
13+
14+
```sql
15+
CREATE WORKER [ IF NOT EXISTS ] <worker_name>
16+
[ WITH <option_name> = '<option_value>' [ , <option_name> = '<option_value>' , ... ] ]
17+
```
18+
19+
## 参数
20+
21+
| 参数 | 说明 |
22+
|-----------|-------------|
23+
| `IF NOT EXISTS` | 可选。如果 worker 已存在,则成功返回但不做修改。 |
24+
| `<worker_name>` | worker 名称。 |
25+
| `WITH ...` | 可选的逗号分隔键值选项列表。选项名会被规范化为小写。 |
26+
27+
## 示例
28+
29+
创建一个不带选项的 worker:
30+
31+
```sql
32+
CREATE WORKER ingest_worker;
33+
```
34+
35+
创建一个带自定义选项的 worker:
36+
37+
```sql
38+
CREATE WORKER IF NOT EXISTS ingest_worker
39+
WITH region = 'us-east-1', pool = 'etl';
40+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: DROP WORKER
3+
sidebar_position: 3
4+
---
5+
6+
删除一个 worker。
7+
8+
:::note
9+
此命令需要启用 cloud control。
10+
:::
11+
12+
## 语法
13+
14+
```sql
15+
DROP WORKER [ IF EXISTS ] <worker_name>
16+
```
17+
18+
## 参数
19+
20+
| 参数 | 说明 |
21+
|-----------|-------------|
22+
| `IF EXISTS` | 可选。如果 worker 不存在,则忽略错误。 |
23+
| `<worker_name>` | worker 名称。 |
24+
25+
## 示例
26+
27+
```sql
28+
DROP WORKER ingest_worker;
29+
```
30+
31+
```sql
32+
DROP WORKER IF EXISTS ingest_worker;
33+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: 工作节点(Worker)
3+
---
4+
5+
适用于启用了 cloud control 的部署的 Worker 相关 SQL 命令。
6+
7+
:::note
8+
Worker 管理命令依赖 cloud control。如果未配置 `cloud_control_grpc_server_address`,执行这些命令时 Databend 会返回 `CloudControlNotEnabled` 错误。
9+
:::
10+
11+
## 支持的语句
12+
13+
| 语句 | 用途 |
14+
|-----------|---------|
15+
| `CREATE WORKER` | 创建 worker,并可附带键值形式的选项 |
16+
| `ALTER WORKER` | 更新 worker 的标签、选项或运行状态 |
17+
| `DROP WORKER` | 删除 worker |
18+
| `SHOW WORKERS` | 列出当前 tenant 下的 worker |
19+
20+
## 命令参考
21+
22+
| 命令 | 描述 |
23+
|---------|-------------|
24+
| [CREATE WORKER](create-worker.md) | 创建 worker 定义 |
25+
| [ALTER WORKER](alter-worker.md) | 修改 worker 的标签、选项或状态 |
26+
| [DROP WORKER](drop-worker.md) | 删除 worker 定义 |
27+
| [SHOW WORKERS](show-workers.md) | 查看 worker 及其元数据 |
28+
29+
## 说明
30+
31+
- 选项名不区分大小写,Databend 在规划阶段会将它们规范化为小写。
32+
- `SHOW WORKERS` 返回 `name``tags``options``created_at``updated_at` 列。
33+
- `ALTER WORKER` 支持 `SET TAG``UNSET TAG``SET``UNSET``SUSPEND``RESUME`
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: SHOW WORKERS
3+
sidebar_position: 4
4+
---
5+
6+
列出当前 tenant 下的 worker。
7+
8+
:::note
9+
此命令需要启用 cloud control。
10+
:::
11+
12+
## 语法
13+
14+
```sql
15+
SHOW WORKERS
16+
```
17+
18+
## 输出
19+
20+
`SHOW WORKERS` 返回以下列:
21+
22+
| 列名 | 说明 |
23+
|--------|-------------|
24+
| `name` | worker 名称 |
25+
| `tags` | JSON 格式的 worker 标签 |
26+
| `options` | JSON 格式的 worker 选项 |
27+
| `created_at` | worker 创建时间 |
28+
| `updated_at` | worker 更新时间 |
29+
30+
## 示例
31+
32+
```sql
33+
SHOW WORKERS;
34+
```

docs/cn/sql-reference/10-sql-commands/00-ddl/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ title: DDL(Data Definition Language)命令
6262
| 组件 | 描述 |
6363
|-----------|-------------|
6464
| **[计算集群 (Warehouse)](19-warehouse/index.md)** | 管理用于查询执行的计算资源 |
65+
| **[工作节点 (Worker)](20-worker/index.md)** | 通过 cloud control 管理 worker 资源 |
6566
| **[工作负载组 (Workload Group)](20-workload-group/index.md)** | 控制资源分配和优先级 |
6667
| **[事务 (Transaction)](14-transaction/index.md)** | 管理数据库事务 |
6768
| **[变量 (Variable)](15-variable/index.md)** | 设置和使用会话/全局变量 |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Worker",
3+
"position": 20
4+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: ALTER WORKER
3+
sidebar_position: 2
4+
---
5+
6+
Modifies a worker's tags, options, or state.
7+
8+
:::note
9+
This command requires cloud control to be enabled.
10+
:::
11+
12+
## Syntax
13+
14+
```sql
15+
ALTER WORKER <worker_name> SET TAG <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ]
16+
17+
ALTER WORKER <worker_name> UNSET TAG <tag_name> [ , <tag_name> , ... ]
18+
19+
ALTER WORKER <worker_name> SET <option_name> = '<option_value>' [ , <option_name> = '<option_value>' , ... ]
20+
21+
ALTER WORKER <worker_name> UNSET <option_name> [ , <option_name> , ... ]
22+
23+
ALTER WORKER <worker_name> SUSPEND
24+
25+
ALTER WORKER <worker_name> RESUME
26+
```
27+
28+
## Parameters
29+
30+
| Form | Description |
31+
|------|-------------|
32+
| `SET TAG` | Adds or updates worker tags. |
33+
| `UNSET TAG` | Removes one or more worker tags. |
34+
| `SET` | Adds or updates worker options. Option names are normalized to lowercase. |
35+
| `UNSET` | Removes one or more worker options. |
36+
| `SUSPEND` | Suspends the worker. |
37+
| `RESUME` | Resumes the worker. |
38+
39+
## Examples
40+
41+
Set tags on a worker:
42+
43+
```sql
44+
ALTER WORKER ingest_worker
45+
SET TAG environment = 'prod', team = 'data-platform';
46+
```
47+
48+
Update worker options:
49+
50+
```sql
51+
ALTER WORKER ingest_worker
52+
SET region = 'us-west-2', pool = 'streaming';
53+
```
54+
55+
Remove a tag and an option:
56+
57+
```sql
58+
ALTER WORKER ingest_worker UNSET TAG team;
59+
ALTER WORKER ingest_worker UNSET pool;
60+
```
61+
62+
Change worker state:
63+
64+
```sql
65+
ALTER WORKER ingest_worker SUSPEND;
66+
ALTER WORKER ingest_worker RESUME;
67+
```
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: CREATE WORKER
3+
sidebar_position: 1
4+
---
5+
6+
Creates a worker.
7+
8+
:::note
9+
This command requires cloud control to be enabled.
10+
:::
11+
12+
## Syntax
13+
14+
```sql
15+
CREATE WORKER [ IF NOT EXISTS ] <worker_name>
16+
[ WITH <option_name> = '<option_value>' [ , <option_name> = '<option_value>' , ... ] ]
17+
```
18+
19+
## Parameters
20+
21+
| Parameter | Description |
22+
|-----------|-------------|
23+
| `IF NOT EXISTS` | Optional. Succeeds without changes if the worker already exists. |
24+
| `<worker_name>` | The worker name. |
25+
| `WITH ...` | Optional comma-separated key-value options. Option names are normalized to lowercase. |
26+
27+
## Examples
28+
29+
Create a worker without options:
30+
31+
```sql
32+
CREATE WORKER ingest_worker;
33+
```
34+
35+
Create a worker with custom options:
36+
37+
```sql
38+
CREATE WORKER IF NOT EXISTS ingest_worker
39+
WITH region = 'us-east-1', pool = 'etl';
40+
```

0 commit comments

Comments
 (0)