Skip to content

Commit fa56295

Browse files
committed
wh ddl
1 parent 66cfeaa commit fa56295

File tree

11 files changed

+342
-0
lines changed

11 files changed

+342
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"label": "Warehouse"
3+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: ALTER WAREHOUSE
3+
---
4+
import FunctionDescription from '@site/src/components/FunctionDescription';
5+
6+
<FunctionDescription description="Introduced or updated: v1.2.687"/>
7+
8+
Dynamically adjusts the configuration of a warehouse, including adding/removing clusters, renaming clusters, and assigning/unassigning nodes.
9+
10+
## Syntax
11+
12+
```sql
13+
ALTER WAREHOUSE <warehouse_name>
14+
[ADD CLUSTER <cluster_name> [WITH CLUSTER_SIZE = <size>] | (ASSIGN <node_count> NODES FROM <node_group>) ]
15+
| [RENAME CLUSTER <old_cluster_name> TO <new_cluster_name>]
16+
| [DROP CLUSTER <cluster_name>]
17+
| [ASSIGN NODES (ASSIGN <node_count> NODES [FROM <node_group>] FOR <cluster_name>)]
18+
| [UNASSIGN NODES (UNASSIGN <node_count> NODES [FROM <node_group>] FOR <cluster_name>)]
19+
20+
```
21+
22+
## Examples
23+
24+
This example adds a cluster to an existing warehouse:
25+
26+
```sql
27+
ALTER WAREHOUSE test_warehouse ADD CLUSTER test_cluster WITH CLUSTER_SIZE = 3;
28+
```
29+
30+
This example renames an existing cluster:
31+
32+
```sql
33+
ALTER WAREHOUSE test_warehouse RENAME CLUSTER default TO test_cluster_2;
34+
```
35+
36+
This example removes an existing cluster:
37+
38+
```sql
39+
ALTER WAREHOUSE test_warehouse DROP CLUSTER test_cluster_2;
40+
```
41+
42+
This example adds nodes to an existing warehouse:
43+
44+
```sql
45+
ALTER WAREHOUSE test_warehouse ASSIGN NODES (ASSIGN 2 NODES FOR test_cluster);
46+
```
47+
48+
This example removes nodes from an existing warehouse:
49+
50+
```sql
51+
ALTER WAREHOUSE test_warehouse UNASSIGN NODES (UNASSIGN 1 NODES FOR test_cluster);
52+
```
53+
54+
This example creates a cluster by selecting nodes from specific node groups:
55+
56+
```sql
57+
ALTER WAREHOUSE test_warehouse ADD CLUSTER test_cluster (ASSIGN 1 NODES FROM dev_node, ASSIGN 1 NODES FROM infra_node);
58+
```
59+
60+
This example adds nodes from specific node groups to an existing warehouse:
61+
62+
```sql
63+
ALTER WAREHOUSE test_warehouse ASSIGN NODES (ASSIGN 1 NODES FROM dev_node FOR default, ASSIGN 1 NODES FROM infra_node FOR default);
64+
```
65+
66+
This example removes nodes from specific node groups in a warehouse:
67+
68+
```sql
69+
ALTER WAREHOUSE test_warehouse UNASSIGN NODES (UNASSIGN 1 NODES FROM dev_node FOR default, UNASSIGN 2 NODES FROM infra_node FOR default);
70+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: CREATE WAREHOUSE
3+
---
4+
import FunctionDescription from '@site/src/components/FunctionDescription';
5+
6+
<FunctionDescription description="Introduced or updated: v1.2.687"/>
7+
8+
Creates a warehouse with specified size or by assigning nodes from specific node groups.
9+
10+
## Syntax
11+
12+
```sql
13+
CREATE WAREHOUSE <warehouse_name>
14+
[WITH warehouse_size = <size> | ASSIGN <node_count> NODES FROM <node_group>[, <node_count> NODES FROM <node_group> ...]]
15+
```
16+
17+
## Examples
18+
19+
This example creates a warehouse with a size of 10:
20+
21+
```sql
22+
CREATE WAREHOUSE test_warehouse WITH warehouse_size = 10
23+
```
24+
25+
This example creates a warehouse by assigning specific nodes from node groups:
26+
27+
```sql
28+
CREATE WAREHOUSE test_warehouse (ASSIGN 1 NODES FROM log_node, ASSIGN 2 NODES FROM infra_node);
29+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: DROP WAREHOUSE
3+
---
4+
import FunctionDescription from '@site/src/components/FunctionDescription';
5+
6+
<FunctionDescription description="Introduced or updated: v1.2.687"/>
7+
8+
Removes the specified warehouse and frees up the resources associated with it.
9+
10+
## Syntax
11+
12+
```sql
13+
DROP WAREHOUSE <warehouse_name>
14+
```
15+
16+
## Examples
17+
18+
This example removes the `test_warehouse` warehouse:
19+
20+
```sql
21+
DROP WAREHOUSE test_warehouse;
22+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Warehouse
3+
---
4+
import IndexOverviewList from '@site/src/components/IndexOverviewList';
5+
6+
This page provides reference information for the warehouse-related commands in Databend.
7+
8+
<IndexOverviewList />
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: RENAME WAREHOUSE
3+
---
4+
import FunctionDescription from '@site/src/components/FunctionDescription';
5+
6+
<FunctionDescription description="Introduced or updated: v1.2.687"/>
7+
8+
Renames an existing warehouse to a new name.
9+
10+
When you rename a warehouse, the session will encounter an error if trying to USE the renamed warehouse without first exiting and reconnecting. This is because the session still references the old warehouse name. To resolve this issue, exit the current session and then reconnect before attempting to use the renamed warehouse.
11+
12+
```sql title='Example:'
13+
root@(test_warehouse_1)/default> rename warehouse test_warehouse_1 to test_warehouse;
14+
15+
rename warehouse test_warehouse_1 to test_warehouse
16+
17+
0 row read in 0.027 sec. Processed 0 row, 0 B (0 row/s, 0 B/s)
18+
19+
root@(test_warehouse_1)/default> use warehouse test_warehouse;
20+
error: APIError: fail to POST http://localhost:8000/v1/query: BadRequest:(500 Internal Server Error)[500]Some(500) UnknownWarehouse. Code: 2406, Text = Unknown warehouse or self managed warehouse "test_warehouse_1"
21+
(while in warehouse request forward).
22+
23+
root@(test_warehouse_1)/default> exit
24+
Bye~
25+
26+
root@localhost:8000/default> use warehouse test_warehouse;
27+
28+
use warehouse test_warehouse
29+
30+
0 row read in 0.019 sec. Processed 0 row, 0 B (0 row/s, 0 B/s)
31+
```
32+
33+
## Syntax
34+
35+
```sql
36+
RENAME WAREHOUSE <current_name> TO <new_name>
37+
```
38+
39+
## Examples
40+
41+
This example renames `test_warehouse_1` to `test_warehouse`:
42+
43+
```sql
44+
RENAME WAREHOUSE test_warehouse_1 TO test_warehouse;
45+
```
46+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: RESUME WAREHOUSE
3+
---
4+
import FunctionDescription from '@site/src/components/FunctionDescription';
5+
6+
<FunctionDescription description="Introduced or updated: v1.2.687"/>
7+
8+
Restarts a previously suspended warehouse, bringing it back online and re-allocating its machine resources. If there are no available nodes, the RESUME WAREHOUSE command will fail. When trying to resume a warehouse, ensure that the necessary resources are available for the warehouse to restart successfully.
9+
10+
## Syntax
11+
12+
```sql
13+
RESUME WAREHOUSE <warehouse_name>
14+
```
15+
16+
## Examples
17+
18+
This example resumes the `test_warehouse` warehouse:
19+
20+
```sql
21+
RESUME WAREHOUSE test_warehouse;
22+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: SHOW ONLINE NODES
3+
---
4+
import FunctionDescription from '@site/src/components/FunctionDescription';
5+
6+
<FunctionDescription description="Introduced or updated: v1.2.687"/>
7+
8+
Lists all currently online nodes within the tenant, showing details such as node ID, type, node group, warehouse, cluster, and version.
9+
10+
## Syntax
11+
12+
```sql
13+
SHOW ONLINE NODES
14+
```
15+
16+
## Examples
17+
18+
```sql
19+
SHOW ONLINE NODES;
20+
21+
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
22+
│ id │ type │ node_group │ warehouse │ cluster │ version │
23+
├────────────────────────┼───────────────┼────────────┼───────────┼─────────┼─────────────────────────────┤
24+
│ 9rabYMxa0ReDyZe6F9igH5 │ SystemManaged │ log_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
25+
│ CbzfLlTVO29EhkZXdeR625 │ SystemManaged │ log_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
26+
│ O0kOetbvkFjxrQ2kx4uMI │ SystemManaged │ dev_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
27+
│ R2epWlGVd8S0maSTuwbsv4 │ SystemManaged │ dev_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
28+
│ SoZcaT4gmhVoGKcChlDw93 │ SystemManaged │ infra_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
29+
│ UeNVzwHCXhxJTTB4Xonj07 │ SystemManaged │ dev_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
30+
│ Zu7rmhVZ2s2HqTUCdFBdu2 │ SystemManaged │ infra_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
31+
│ bRubWZEzIibFgRgFad2MS3 │ SystemManaged │ infra_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
32+
│ ilPer0ps5wWnEDOLIlk821 │ SystemManaged │ infra_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
33+
│ shnWu1TC41sAxVwJMIVQF3 │ SystemManaged │ infra_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
34+
└─────────────────────────────────────────────────────────────────────────────────────────────────────────┘
35+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: SHOW WAREHOUSES
3+
---
4+
import FunctionDescription from '@site/src/components/FunctionDescription';
5+
6+
<FunctionDescription description="Introduced or updated: v1.2.687"/>
7+
8+
Returns a list of all existing warehouses along with their type and status.
9+
10+
## Syntax
11+
12+
```sql
13+
SHOW WAREHOUSES
14+
```
15+
16+
## Examples
17+
18+
```sql
19+
SHOW WAREHOUSES;
20+
21+
┌───────────────────────────────────────────┐
22+
│ warehouse │ type │ status │
23+
├────────────────┼────────────────┼─────────┤
24+
│ test_warehouse │ System-Managed │ Running │
25+
└───────────────────────────────────────────┘
26+
```
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: SUSPEND WAREHOUSE
3+
---
4+
import FunctionDescription from '@site/src/components/FunctionDescription';
5+
6+
<FunctionDescription description="Introduced or updated: v1.2.687"/>
7+
8+
Suspends a warehouse, releasing the associated machine resources, but does not delete the warehouse.
9+
10+
When you suspend a warehouse, it releases the machine resources associated with the warehouse. However, this action can cause issues when attempting to interact with the warehouse. Specifically, if you try to use or query a suspended warehouse, you may encounter errors indicating that the warehouse is unavailable. For example, attempting to run SHOW ONLINE NODES or other commands that reference the suspended warehouse will result in an error. To resolve this, you need to exit the current session and reconnect.
11+
12+
```sql title='Example:'
13+
root@(test_warehouse)/default> suspend warehouse test_warehouse;
14+
15+
suspend warehouse test_warehouse
16+
17+
0 row read in 0.036 sec. Processed 0 row, 0 B (0 row/s, 0 B/s)
18+
19+
root@(test_warehouse)/default> show online nodes;
20+
error: APIError: fail to POST http://localhost:8000/v1/query: BadRequest:(400 Bad Request)[400]Some(400) UnknownWarehouse. Code: 2406, Text = Not find the 'test_warehouse' warehouse; it is possible that all nodes of the warehouse have gone offline. Please exit the client and reconnect, or use `use warehouse <new_warehouse>`.
21+
22+
root@(test_warehouse_1)/default> exit
23+
Bye~
24+
25+
root@localhost:8000/default> show online nodes;
26+
27+
show online nodes
28+
29+
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
30+
│ id │ type │ node_group │ warehouse │ cluster │ version │
31+
│ String │ String │ String │ String │ String │ String │
32+
├────────────────────────┼───────────────┼────────────┼───────────┼─────────┼─────────────────────────────┤
33+
│ 9rabYMxa0ReDyZe6F9igH5 │ SystemManaged │ log_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
34+
│ CbzfLlTVO29EhkZXdeR625 │ SystemManaged │ log_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
35+
│ O0kOetbvkFjxrQ2kx4uMI │ SystemManaged │ dev_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
36+
│ R2epWlGVd8S0maSTuwbsv4 │ SystemManaged │ dev_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
37+
│ SoZcaT4gmhVoGKcChlDw93 │ SystemManaged │ infra_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
38+
│ UeNVzwHCXhxJTTB4Xonj07 │ SystemManaged │ dev_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
39+
│ Zu7rmhVZ2s2HqTUCdFBdu2 │ SystemManaged │ infra_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
40+
│ bRubWZEzIibFgRgFad2MS3 │ SystemManaged │ infra_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
41+
│ ilPer0ps5wWnEDOLIlk821 │ SystemManaged │ infra_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
42+
│ shnWu1TC41sAxVwJMIVQF3 │ SystemManaged │ infra_node │ │ │ v1.2.665-nightly-bcb2c16f67 │
43+
└─────────────────────────────────────────────────────────────────────────────────────────────────────────┘
44+
10 rows read in 0.133 sec. Processed 0 rows, 0 B (0 row/s, 0 B/s)
45+
```
46+
47+
## Syntax
48+
49+
```sql
50+
SUSPEND WAREHOUSE <warehouse_name>
51+
```
52+
53+
## Examples
54+
55+
This example suspends the `test_warehouse` warehouse:
56+
57+
```sql
58+
SUSPEND WAREHOUSE test_warehouse;
59+
```

0 commit comments

Comments
 (0)