@clickzetta/cz-cli-darwin-x64 0.3.91 → 0.3.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cz-cli +0 -0
- package/bin/skills/clickzetta-ai-function/SKILL.md +109 -0
- package/bin/skills/clickzetta-ai-function/eval_cases.jsonl +4 -0
- package/bin/skills/clickzetta-ai-function/references/ai-function-ddl.md +106 -0
- package/bin/skills/clickzetta-batch-sync-pipeline/SKILL.md +124 -124
- package/bin/skills/clickzetta-batch-sync-pipeline/eval_cases.jsonl +5 -5
- package/bin/skills/clickzetta-bi-connect/SKILL.md +79 -78
- package/bin/skills/clickzetta-bi-connect/references/bi-tools.md +56 -56
- package/bin/skills/clickzetta-cdc-sync-pipeline/SKILL.md +386 -382
- package/bin/skills/clickzetta-cdc-sync-pipeline/eval_cases.jsonl +5 -5
- package/bin/skills/clickzetta-data-ingest-pipeline/SKILL.md +73 -212
- package/bin/skills/clickzetta-data-science/SKILL.md +57 -56
- package/bin/skills/clickzetta-data-science/references/bitmap-profile.md +38 -38
- package/bin/skills/clickzetta-data-science/references/data-patterns.md +16 -16
- package/bin/skills/clickzetta-data-science/references/setup.md +28 -28
- package/bin/skills/clickzetta-data-science/references/stats-functions.md +44 -44
- package/bin/skills/clickzetta-data-science/references/write-and-infer.md +22 -22
- package/bin/skills/clickzetta-data-science/references/zettapark-api.md +32 -32
- package/bin/skills/clickzetta-dw-modeling/SKILL.md +1 -1
- package/bin/skills/clickzetta-external-function/SKILL.md +51 -109
- package/bin/skills/clickzetta-external-function/eval_cases.jsonl +4 -4
- package/bin/skills/clickzetta-external-function/references/external-function-ddl.md +39 -77
- package/bin/skills/clickzetta-java-sdk/SKILL.md +49 -48
- package/bin/skills/clickzetta-java-sdk/eval_cases.jsonl +12 -12
- package/bin/skills/clickzetta-java-sdk/references/bulkload.md +34 -34
- package/bin/skills/clickzetta-java-sdk/references/realtime.md +44 -44
- package/bin/skills/clickzetta-kafka-ingest-pipeline/SKILL.md +273 -507
- package/bin/skills/clickzetta-kafka-ingest-pipeline/references/kafka-pipe-syntax.md +197 -231
- package/bin/skills/clickzetta-oss-ingest-pipeline/SKILL.md +231 -304
- package/bin/skills/clickzetta-realtime-sync-pipeline/SKILL.md +180 -179
- package/bin/skills/clickzetta-realtime-sync-pipeline/eval_cases.jsonl +5 -5
- package/bin/skills/clickzetta-semantic-view/SKILL.md +74 -72
- package/bin/skills/clickzetta-semantic-view/eval_cases.jsonl +12 -12
- package/bin/skills/clickzetta-semantic-view/references/semantic-view-reference.md +75 -75
- package/bin/skills/clickzetta-sql-migration/SKILL.md +128 -0
- package/bin/skills/clickzetta-sql-migration/eval_cases.jsonl +10 -0
- package/bin/skills/clickzetta-sql-migration/references/ddl-reference.md +350 -0
- package/bin/skills/clickzetta-sql-migration/references/dml-differences.md +192 -0
- package/bin/skills/clickzetta-sql-migration/references/dml-reference.md +279 -0
- package/bin/skills/{clickzetta-sql-syntax-guide → clickzetta-sql-migration}/references/dql-reference.md +128 -128
- package/bin/skills/clickzetta-sql-migration/references/function-mapping.md +194 -0
- package/bin/skills/clickzetta-sql-migration/references/functions-reference.md +372 -0
- package/bin/skills/clickzetta-sql-migration/references/implicit-type-conversion.md +143 -0
- package/bin/skills/clickzetta-sql-migration/references/migration-databricks.md +260 -0
- package/bin/skills/{clickzetta-sql-syntax-guide → clickzetta-sql-migration}/references/migration-snowflake.md +112 -112
- package/bin/skills/clickzetta-sql-migration/references/vs-snowflake.md +346 -0
- package/bin/skills/clickzetta-sql-migration/references/vs-spark.md +229 -0
- package/bin/skills/clickzetta-studio-task-manager/SKILL.md +326 -329
- package/bin/skills/clickzetta-table-lineage/SKILL.md +57 -55
- package/bin/skills/clickzetta-table-lineage/eval_cases.jsonl +1 -1
- package/bin/skills/clickzetta-table-lineage/references/normalize_func.sql +5 -5
- package/bin/skills/clickzetta-table-lineage/references/table_cost.sql +6 -6
- package/bin/skills/clickzetta-table-lineage/references/table_relation.sql +2 -2
- package/bin/skills/clickzetta-volume-manager/SKILL.md +186 -100
- package/bin/skills/clickzetta-volume-manager/references/volume-ddl.md +153 -52
- package/package.json +1 -1
- package/bin/skills/clickzetta-dynamic-table/best-practices/scheduling-guide.md +0 -135
- package/bin/skills/clickzetta-dynamic-table/dt-creator/references/dt-declaration-strategy.md +0 -185
- package/bin/skills/clickzetta-dynamic-table/dt-creator/references/refresh-history-guide.md +0 -260
- package/bin/skills/clickzetta-dynamic-table/dynamic-table-alter/SKILL.md +0 -191
- package/bin/skills/clickzetta-sql-syntax-guide/SKILL.md +0 -249
- package/bin/skills/clickzetta-sql-syntax-guide/eval_cases.jsonl +0 -3
- package/bin/skills/clickzetta-sql-syntax-guide/references/ddl-reference.md +0 -350
- package/bin/skills/clickzetta-sql-syntax-guide/references/dml-reference.md +0 -279
- package/bin/skills/clickzetta-sql-syntax-guide/references/functions-reference.md +0 -372
- package/bin/skills/clickzetta-sql-syntax-guide/references/migration-databricks.md +0 -260
- package/bin/skills/clickzetta-sql-syntax-guide/references/vs-snowflake.md +0 -346
- package/bin/skills/clickzetta-sql-syntax-guide/references/vs-spark.md +0 -229
- /package/bin/skills/{clickzetta-sql-syntax-guide → clickzetta-sql-migration}/LICENSE +0 -0
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
# Dynamic Table Incremental Refresh History Query Guide
|
|
2
|
-
|
|
3
|
-
There are three ways to view the incremental refresh history of a DT/MV, each suited to different scenarios.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Method 1: SHOW DYNAMIC TABLE REFRESH HISTORY
|
|
8
|
-
|
|
9
|
-
View job-level information for DT refreshes, including the status, duration, trigger type, and refresh mode of each refresh.
|
|
10
|
-
|
|
11
|
-
### Syntax
|
|
12
|
-
|
|
13
|
-
```sql
|
|
14
|
-
-- Filter by WHERE (name column matches table name)
|
|
15
|
-
SHOW DYNAMIC TABLE REFRESH HISTORY WHERE name = 'my_dt';
|
|
16
|
-
|
|
17
|
-
-- Combine WHERE + LIMIT
|
|
18
|
-
SHOW DYNAMIC TABLE REFRESH HISTORY WHERE name = 'my_dt' AND state = 'SUCCEED' LIMIT 20;
|
|
19
|
-
|
|
20
|
-
-- MV supports the same syntax
|
|
21
|
-
SHOW MATERIALIZED VIEW REFRESH HISTORY WHERE name = 'my_mv' LIMIT 10;
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Output Columns
|
|
25
|
-
|
|
26
|
-
| Column | Type | Description |
|
|
27
|
-
|------|------|------|
|
|
28
|
-
| workspace_name | STRING | Workspace the DT/MV belongs to |
|
|
29
|
-
| schema_name | STRING | Schema the DT/MV belongs to |
|
|
30
|
-
| name | STRING | DT/MV name |
|
|
31
|
-
| virtual_cluster | STRING | Virtual cluster that executed the refresh |
|
|
32
|
-
| start_time | TIMESTAMP | Refresh start time |
|
|
33
|
-
| end_time | TIMESTAMP | Refresh end time (NULL while running) |
|
|
34
|
-
| duration | INTERVAL | Refresh duration (shows elapsed time while running) |
|
|
35
|
-
| state | STRING | Refresh status (SUCCEED / FAILED / RUNNING, etc.) |
|
|
36
|
-
| refresh_trigger | STRING | Trigger type: `SYSTEM_SCHEDULED` (auto-triggered by system) or `MANUAL` (user manually triggered REFRESH) |
|
|
37
|
-
| refresh_mode | STRING | Refresh mode; see detailed description below |
|
|
38
|
-
| error_message | STRING | Error message on failure (NULL on success) |
|
|
39
|
-
| source_tables | ARRAY<MAP<STRING,STRING>> | Source table list; each element is a MAP with keys `workspace`, `schema`, `table_name` |
|
|
40
|
-
| stats | MAP<STRING,STRING> | Refresh statistics, including `rows_inserted` and `rows_deleted` |
|
|
41
|
-
| job_id | STRING | Corresponding Job ID; can be used to join `information_schema.job_history` for more details |
|
|
42
|
-
|
|
43
|
-
### refresh_mode Details
|
|
44
|
-
|
|
45
|
-
`refresh_mode` is the key field for determining whether incremental computation is working:
|
|
46
|
-
|
|
47
|
-
| Value | Meaning | Description |
|
|
48
|
-
|----|------|------|
|
|
49
|
-
| `INCREMENTAL` | Incremental refresh | The incremental engine successfully generated an incremental plan and only processed change data from source tables |
|
|
50
|
-
| `FULL` | Full refresh | Fell back to full recomputation. Possible reasons: first refresh, dimension table change, incremental plan generation failed, user forced full, etc. |
|
|
51
|
-
| `NO_DATA` | No data changes | No new data changes in source tables since the last refresh; this refresh skipped computation |
|
|
52
|
-
|
|
53
|
-
### source_tables Details
|
|
54
|
-
|
|
55
|
-
The `source_tables` column returns information about all input tables involved in this refresh; each element is a MAP:
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
[
|
|
59
|
-
{"workspace": "my_ws", "schema": "public", "table_name": "orders"},
|
|
60
|
-
{"workspace": "my_ws", "schema": "public", "table_name": "dim_product"}
|
|
61
|
-
]
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### stats Details
|
|
65
|
-
|
|
66
|
-
The `stats` column returns write statistics for the target table from this refresh:
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
{"rows_inserted": "1000", "rows_deleted": "50"}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
- `rows_inserted`: number of rows inserted into the target table in this refresh
|
|
73
|
-
- `rows_deleted`: number of rows deleted from the target table in this refresh (in incremental mode, update operations produce delete + insert)
|
|
74
|
-
|
|
75
|
-
### Typical Usage
|
|
76
|
-
|
|
77
|
-
```sql
|
|
78
|
-
-- View failed refresh records
|
|
79
|
-
SHOW DYNAMIC TABLE REFRESH HISTORY WHERE name = 'my_dt' AND state = 'FAILED';
|
|
80
|
-
|
|
81
|
-
-- Check if it fell back to full refresh (troubleshoot whether incremental is working)
|
|
82
|
-
SHOW DYNAMIC TABLE REFRESH HISTORY WHERE name = 'my_dt' AND refresh_mode = 'FULL';
|
|
83
|
-
|
|
84
|
-
-- View no-data-change refreshes (appears when source table has no new data)
|
|
85
|
-
SHOW DYNAMIC TABLE REFRESH HISTORY WHERE name = 'my_dt' AND refresh_mode = 'NO_DATA';
|
|
86
|
-
|
|
87
|
-
-- View system auto-scheduled refreshes
|
|
88
|
-
SHOW DYNAMIC TABLE REFRESH HISTORY WHERE name = 'my_dt' AND refresh_trigger = 'SYSTEM_SCHEDULED';
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## Method 2: DESC HISTORY
|
|
94
|
-
|
|
95
|
-
View version-level history of a table, including row count, bytes, and operation type for each version. Useful for understanding data change granularity.
|
|
96
|
-
|
|
97
|
-
### Syntax
|
|
98
|
-
|
|
99
|
-
```sql
|
|
100
|
-
-- View version history of a DT
|
|
101
|
-
DESC HISTORY my_dt;
|
|
102
|
-
|
|
103
|
-
-- View version history of a source table
|
|
104
|
-
DESC HISTORY source_table;
|
|
105
|
-
|
|
106
|
-
-- Supports WHERE filtering
|
|
107
|
-
DESC HISTORY my_dt WHERE version > 10;
|
|
108
|
-
|
|
109
|
-
-- Supports LIMIT
|
|
110
|
-
DESC HISTORY my_dt LIMIT 20;
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Output Columns
|
|
114
|
-
|
|
115
|
-
For regular tables (DESC_TABLE_HISTORY):
|
|
116
|
-
|
|
117
|
-
| Column | Type | Description |
|
|
118
|
-
|------|------|------|
|
|
119
|
-
| sequence | BIGINT | Sequence number |
|
|
120
|
-
| version | BIGINT | Version number |
|
|
121
|
-
| time | TIMESTAMP | Version creation time |
|
|
122
|
-
| total_rows | BIGINT | Total row count for this version |
|
|
123
|
-
| total_bytes | BIGINT | Total bytes for this version |
|
|
124
|
-
| user | STRING | User who performed the operation |
|
|
125
|
-
| operation | STRING | Operation type (INSERT / COMPACTION / REFRESH, etc.) |
|
|
126
|
-
| job_id | STRING | Corresponding Job ID |
|
|
127
|
-
|
|
128
|
-
For DT/MV (DESC_MV_HISTORY), additionally includes:
|
|
129
|
-
|
|
130
|
-
| Column | Type | Description |
|
|
131
|
-
|------|------|------|
|
|
132
|
-
| source_tables | ARRAY<MAP<STRING,STRING>> | Source tables and their corresponding version information |
|
|
133
|
-
|
|
134
|
-
DESC HISTORY's `source_tables` for DT/MV is more detailed than SHOW REFRESH HISTORY, including snapshot information for each source table at that version:
|
|
135
|
-
|
|
136
|
-
```
|
|
137
|
-
[
|
|
138
|
-
{"table_name": "orders", "workspace": "my_ws", "schema": "public", "version": "123", "sequence": "5", "commit_time": "2025-01-15 10:30:00"},
|
|
139
|
-
{"table_name": "dim_product", "workspace": "my_ws", "schema": "public", "version": "456", "sequence": "2", "commit_time": "2025-01-15 08:00:00"}
|
|
140
|
-
]
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
- `version`: snapshot_id of the source table
|
|
144
|
-
- `sequence`: sequence number of the source table
|
|
145
|
-
- `commit_time`: commit time of that version of the source table
|
|
146
|
-
|
|
147
|
-
This information can be used to trace which version of source table data was read in a given refresh.
|
|
148
|
-
|
|
149
|
-
### Typical Usage
|
|
150
|
-
|
|
151
|
-
```sql
|
|
152
|
-
-- View recent version changes of a DT; confirm compaction is executing normally
|
|
153
|
-
DESC HISTORY my_dt LIMIT 10;
|
|
154
|
-
|
|
155
|
-
-- View version history of a source table; determine data write frequency
|
|
156
|
-
DESC HISTORY source_table LIMIT 20;
|
|
157
|
-
|
|
158
|
-
-- View compaction records of a DT
|
|
159
|
-
DESC HISTORY my_dt WHERE operation = 'COMPACTION';
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## Method 3: information_schema.materialized_view_refresh_history
|
|
165
|
-
|
|
166
|
-
Query refresh history from information_schema; suitable for cross-table batch analysis, integration with other systems, or long-term trend monitoring. Data is partitioned by day (pt_date); retention days are determined by system configuration.
|
|
167
|
-
|
|
168
|
-
### Syntax
|
|
169
|
-
|
|
170
|
-
```sql
|
|
171
|
-
-- View refresh history for a specific DT
|
|
172
|
-
SELECT *
|
|
173
|
-
FROM information_schema.materialized_view_refresh_history
|
|
174
|
-
WHERE materialized_view_name = 'my_dt'
|
|
175
|
-
ORDER BY start_time DESC
|
|
176
|
-
LIMIT 10;
|
|
177
|
-
|
|
178
|
-
-- View refresh status of all DTs on a given day
|
|
179
|
-
SELECT materialized_view_name, status, start_time, end_time, error_message
|
|
180
|
-
FROM information_schema.materialized_view_refresh_history
|
|
181
|
-
WHERE pt_date = '2025-01-15'
|
|
182
|
-
ORDER BY start_time DESC;
|
|
183
|
-
|
|
184
|
-
-- View failed refreshes
|
|
185
|
-
SELECT materialized_view_name, error_code, error_message, start_time
|
|
186
|
-
FROM information_schema.materialized_view_refresh_history
|
|
187
|
-
WHERE status = 'FAILED' AND pt_date >= '2025-01-01'
|
|
188
|
-
ORDER BY start_time DESC;
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Output Columns
|
|
192
|
-
|
|
193
|
-
| Column | Type | Description |
|
|
194
|
-
|------|------|------|
|
|
195
|
-
| workspace_name | STRING | Workspace the DT/MV belongs to |
|
|
196
|
-
| schema_name | STRING | Schema the DT/MV belongs to |
|
|
197
|
-
| materialized_view_name | STRING | DT/MV name |
|
|
198
|
-
| cru | DOUBLE | Compute resource units consumed |
|
|
199
|
-
| virtual_cluster_name | STRING | Virtual cluster that executed the refresh |
|
|
200
|
-
| status | STRING | Refresh status |
|
|
201
|
-
| scheduled_start_time | TIMESTAMP | Scheduled start time |
|
|
202
|
-
| start_time | TIMESTAMP | Actual start time |
|
|
203
|
-
| end_time | TIMESTAMP | End time |
|
|
204
|
-
| error_code | STRING | Error code |
|
|
205
|
-
| error_message | STRING | Error message |
|
|
206
|
-
| pt_date | STRING | Partition date |
|
|
207
|
-
|
|
208
|
-
### Typical Usage
|
|
209
|
-
|
|
210
|
-
```sql
|
|
211
|
-
-- Calculate the refresh success rate of a DT over the last 7 days
|
|
212
|
-
SELECT
|
|
213
|
-
pt_date,
|
|
214
|
-
COUNT(*) AS total,
|
|
215
|
-
SUM(CASE WHEN status = 'SUCCEED' THEN 1 ELSE 0 END) AS success,
|
|
216
|
-
SUM(CASE WHEN status = 'FAILED' THEN 1 ELSE 0 END) AS failed
|
|
217
|
-
FROM information_schema.materialized_view_refresh_history
|
|
218
|
-
WHERE materialized_view_name = 'my_dt'
|
|
219
|
-
AND pt_date >= DATE_FORMAT(DATEADD(DAY, -7, CURRENT_DATE()), '%Y-%m-%d')
|
|
220
|
-
GROUP BY pt_date
|
|
221
|
-
ORDER BY pt_date;
|
|
222
|
-
|
|
223
|
-
-- View refreshes that consumed the most CRU
|
|
224
|
-
SELECT materialized_view_name, cru, start_time, end_time
|
|
225
|
-
FROM information_schema.materialized_view_refresh_history
|
|
226
|
-
WHERE pt_date >= '2025-01-01'
|
|
227
|
-
ORDER BY cru DESC
|
|
228
|
-
LIMIT 10;
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### Difference from information_schema.job_history
|
|
232
|
-
|
|
233
|
-
`information_schema.job_history` records all types of Jobs (SQL queries, DML, DDL, etc.), while `materialized_view_refresh_history` specifically records DT/MV refresh history with more targeted fields.
|
|
234
|
-
|
|
235
|
-
If you need to view complete information about a refresh Job (e.g., job_text, input_bytes, etc.), you can join via job_id:
|
|
236
|
-
|
|
237
|
-
```sql
|
|
238
|
-
-- Get job_id from SHOW DYNAMIC TABLE REFRESH HISTORY, then look up details in job_history
|
|
239
|
-
SELECT *
|
|
240
|
-
FROM information_schema.job_history
|
|
241
|
-
WHERE job_id = '<job_id from SHOW REFRESH HISTORY>'
|
|
242
|
-
AND pt_date = '2025-01-15';
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
---
|
|
246
|
-
|
|
247
|
-
## Comparison of Three Methods
|
|
248
|
-
|
|
249
|
-
| Feature | SHOW REFRESH HISTORY | DESC HISTORY | information_schema |
|
|
250
|
-
|------|---------------------|--------------|-------------------|
|
|
251
|
-
| Granularity | Refresh job level | Table version level | Refresh job level |
|
|
252
|
-
| Refresh mode (incremental/full/no data) | ✅ refresh_mode | ❌ | ❌ |
|
|
253
|
-
| Trigger type (scheduled/manual) | ✅ refresh_trigger | ❌ | ❌ |
|
|
254
|
-
| Write statistics (inserted/deleted) | ✅ stats | ❌ | ❌ |
|
|
255
|
-
| Source table list | ✅ table name level | ✅ includes version/sequence/commit_time | ❌ |
|
|
256
|
-
| Version number / total rows / total bytes | ❌ | ✅ version/total_rows/total_bytes | ❌ |
|
|
257
|
-
| CRU consumption | ❌ | ❌ | ✅ cru |
|
|
258
|
-
| Cross-table batch queries | ❌ (single table) | ❌ (single table) | ✅ (batch supported) |
|
|
259
|
-
| Compaction records | ❌ | ✅ | ❌ |
|
|
260
|
-
| Applicable scenarios | Troubleshoot whether incremental is working; refresh status | View data version changes; trace source table versions | Batch analysis / monitoring / CRU statistics |
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: dynamic-table-alter
|
|
3
|
-
description: |
|
|
4
|
-
Modify the structure and properties of ClickZetta Dynamic Tables. Supports direct ALTER operations
|
|
5
|
-
(suspend, resume, rename_column, set_comment, set_column_comment, set/unset properties) as well as
|
|
6
|
-
CREATE OR REPLACE rebuild operations (modify refresh interval, compute cluster, add column, drop column,
|
|
7
|
-
change column type, change SQL definition). Triggers when the user says "modify dynamic table",
|
|
8
|
-
"add column to dynamic table", "change refresh interval", or "suspend dynamic table".
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# Dynamic Table Modification Workflow
|
|
12
|
-
|
|
13
|
-
## Instructions
|
|
14
|
-
|
|
15
|
-
### Step 1: Confirm the Dynamic Table Exists and Retrieve Its Current Definition
|
|
16
|
-
Execute `SHOW CREATE TABLE schema_name.table_name` to get the current definition of the Dynamic Table.
|
|
17
|
-
If unsure whether it is a Dynamic Table, first use `SHOW TABLES WHERE is_dynamic` to view the list.
|
|
18
|
-
|
|
19
|
-
### Step 2: Determine the Operation Type and Choose the Execution Method
|
|
20
|
-
|
|
21
|
-
Dynamic Table modification operations fall into two categories:
|
|
22
|
-
|
|
23
|
-
**A. Direct ALTER operations** (6 types, can be executed directly):
|
|
24
|
-
|
|
25
|
-
1. **suspend** — Pause the scheduled refresh:
|
|
26
|
-
```sql
|
|
27
|
-
ALTER DYNAMIC TABLE dt_name SUSPEND;
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
2. **resume** — Start the scheduled refresh:
|
|
31
|
-
```sql
|
|
32
|
-
ALTER DYNAMIC TABLE dt_name RESUME;
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
3. **set_comment** — Modify the table comment:
|
|
36
|
-
```sql
|
|
37
|
-
ALTER DYNAMIC TABLE dt_name SET COMMENT 'comment';
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
4. **rename_column** — Rename a column:
|
|
41
|
-
```sql
|
|
42
|
-
ALTER DYNAMIC TABLE dt_name RENAME COLUMN old_name TO new_name;
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
5. **set_column_comment** — Modify a column comment (note: use CHANGE COLUMN):
|
|
46
|
-
```sql
|
|
47
|
-
ALTER DYNAMIC TABLE dt_name CHANGE COLUMN column_name COMMENT 'comment';
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
6. **set/unset properties** — Modify table properties (currently reserved parameters):
|
|
51
|
-
```sql
|
|
52
|
-
-- Set a property
|
|
53
|
-
ALTER DYNAMIC TABLE dt_name SET PROPERTIES('key' = 'value');
|
|
54
|
-
-- Remove a property
|
|
55
|
-
ALTER DYNAMIC TABLE dt_name UNSET PROPERTIES('key');
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
**B. CREATE OR REPLACE operations** (6 types, require rebuilding the Dynamic Table):
|
|
59
|
-
|
|
60
|
-
> ⚠️ **The following operations do not support ALTER syntax.** Syntax like `ALTER DYNAMIC TABLE ... SET REFRESH INTERVAL` does not exist and will cause a syntax error. You must use `CREATE OR REPLACE DYNAMIC TABLE` to rebuild.
|
|
61
|
-
|
|
62
|
-
These operations involve changes to SQL query logic and cannot be completed via ALTER directly:
|
|
63
|
-
|
|
64
|
-
7. **Modify refresh interval** — ❌ `ALTER ... SET REFRESH INTERVAL` is not supported
|
|
65
|
-
8. **Modify compute cluster** — ❌ `ALTER ... SET VCLUSTER` is not supported
|
|
66
|
-
9. **Add column**
|
|
67
|
-
10. **Drop column**
|
|
68
|
-
11. **Modify column type**
|
|
69
|
-
12. **Modify SQL definition**
|
|
70
|
-
|
|
71
|
-
### Step 3: Execute CREATE OR REPLACE Rebuild (Type B operations only)
|
|
72
|
-
|
|
73
|
-
1. Execute `SHOW CREATE TABLE schema_name.table_name` to get the original DDL
|
|
74
|
-
> ⚠️ `SHOW CREATE TABLE` does not support LIMIT/WHERE clauses; execute it directly
|
|
75
|
-
2. Parse out: column definitions, REFRESH clause, AS SELECT clause, COMMENT, etc.
|
|
76
|
-
3. Modify the relevant parts according to the operation
|
|
77
|
-
4. Execute the rebuild SQL
|
|
78
|
-
|
|
79
|
-
**About full refresh triggers:**
|
|
80
|
-
- Simple drop column / add column (where the added column is simply passed through from the source table without participating in JOIN keys, GROUP keys, or other computations) → **incremental refresh**
|
|
81
|
-
- Changes involving computation logic (modifying WHERE conditions, modifying aggregation logic, new column participates in computation, etc.) → **full refresh**
|
|
82
|
-
- Compatible type changes (e.g., INT → BIGINT) → **incremental refresh**
|
|
83
|
-
|
|
84
|
-
### Step 4: Verify the Modification
|
|
85
|
-
Use `DESC TABLE dt_name` to confirm the modification took effect.
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## Examples
|
|
90
|
-
|
|
91
|
-
### Example 1: Modify Refresh Interval
|
|
92
|
-
|
|
93
|
-
```sql
|
|
94
|
-
-- Original table
|
|
95
|
-
CREATE DYNAMIC TABLE dt_name
|
|
96
|
-
REFRESH INTERVAL 10 MINUTE vcluster DEFAULT
|
|
97
|
-
AS SELECT * FROM student02;
|
|
98
|
-
|
|
99
|
-
-- After modification (changed to 20 minutes)
|
|
100
|
-
CREATE OR REPLACE DYNAMIC TABLE dt_name
|
|
101
|
-
REFRESH INTERVAL 20 MINUTE vcluster DEFAULT
|
|
102
|
-
AS SELECT * FROM student02;
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Example 2: Modify Compute Cluster
|
|
106
|
-
|
|
107
|
-
```sql
|
|
108
|
-
-- Original table
|
|
109
|
-
CREATE DYNAMIC TABLE dt_name
|
|
110
|
-
REFRESH INTERVAL 10 MINUTE vcluster DEFAULT
|
|
111
|
-
AS SELECT * FROM student02;
|
|
112
|
-
|
|
113
|
-
-- After modification (changed to alter_vc cluster)
|
|
114
|
-
CREATE OR REPLACE DYNAMIC TABLE dt_name
|
|
115
|
-
REFRESH INTERVAL 10 MINUTE vcluster alter_vc
|
|
116
|
-
AS SELECT * FROM student02;
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Example 3: Add Column
|
|
120
|
-
|
|
121
|
-
```sql
|
|
122
|
-
-- Original table
|
|
123
|
-
CREATE DYNAMIC TABLE change_table (i, j)
|
|
124
|
-
AS SELECT * FROM dy_base_a;
|
|
125
|
-
|
|
126
|
-
-- Add column col (involves computation logic; next refresh will be a full refresh)
|
|
127
|
-
CREATE OR REPLACE DYNAMIC TABLE change_table (i, j, col)
|
|
128
|
-
AS SELECT i, j, j * 1 FROM dy_base_a;
|
|
129
|
-
|
|
130
|
-
REFRESH DYNAMIC TABLE change_table;
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Example 4: Drop Column
|
|
134
|
-
|
|
135
|
-
```sql
|
|
136
|
-
-- Original table has columns i, j
|
|
137
|
-
CREATE DYNAMIC TABLE change_table (i, j)
|
|
138
|
-
AS SELECT * FROM dy_base_a;
|
|
139
|
-
|
|
140
|
-
-- Drop column (simple pass-through; incremental refresh)
|
|
141
|
-
CREATE OR REPLACE DYNAMIC TABLE change_table (i)
|
|
142
|
-
AS SELECT i FROM dy_base_a;
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Example 5: Modify SQL Definition
|
|
146
|
-
|
|
147
|
-
```sql
|
|
148
|
-
-- Modify WHERE filter condition (full refresh)
|
|
149
|
-
CREATE OR REPLACE DYNAMIC TABLE change_table (i, j)
|
|
150
|
-
AS SELECT * FROM dy_base_a WHERE i > 3;
|
|
151
|
-
|
|
152
|
-
REFRESH DYNAMIC TABLE change_table;
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### Example 6: Modify Column Type
|
|
156
|
-
|
|
157
|
-
```sql
|
|
158
|
-
-- INT → BIGINT (compatible type; incremental refresh)
|
|
159
|
-
CREATE OR REPLACE DYNAMIC TABLE change_table (i, j)
|
|
160
|
-
AS SELECT CAST(i AS BIGINT), j FROM dy_base_a;
|
|
161
|
-
|
|
162
|
-
REFRESH DYNAMIC TABLE change_table;
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## Platform-Specific Knowledge
|
|
168
|
-
|
|
169
|
-
- **CHANGE COLUMN syntax**: set a column comment with `CHANGE COLUMN col COMMENT 'xxx'`, not `ALTER COLUMN`
|
|
170
|
-
- **RENAME COLUMN syntax**: `RENAME COLUMN old TO new`
|
|
171
|
-
- **DML restrictions**: Dynamic Tables do not support UPDATE/DELETE/MERGE by default (due to hidden column MV__KEY); to use DML, first execute `SET cz.sql.dt.allow.dml = true;`
|
|
172
|
-
- **REFRESH format**: `REFRESH INTERVAL <N> MINUTE vcluster <name>`, supports SECOND/MINUTE/HOUR/DAY
|
|
173
|
-
- **CREATE OR REPLACE risk**: changes involving computation logic will trigger a full refresh, which may take a long time for large tables
|
|
174
|
-
- **Schema prefix**: all ALTER/CREATE statements should include the schema prefix in the table name
|
|
175
|
-
- **Column definitions can omit types**: `CREATE DYNAMIC TABLE dt (i, j) AS SELECT ...` — types are inferred from SELECT
|
|
176
|
-
- **DROP syntax**: must use `DROP DYNAMIC TABLE dt_name`; `DROP TABLE dt_name` will cause an error
|
|
177
|
-
- **UNDROP syntax**: must use `UNDROP TABLE dt_name`; `UNDROP DYNAMIC TABLE dt_name` is not supported
|
|
178
|
-
- **DESC syntax**: use `DESC TABLE dt_name` for Dynamic Tables; do not write `DESC DYNAMIC TABLE dt_name EXTENDED` (EXTENDED is not supported)
|
|
179
|
-
|
|
180
|
-
## Troubleshooting
|
|
181
|
-
|
|
182
|
-
| Error | Cause | Solution |
|
|
183
|
-
|---|---|---|
|
|
184
|
-
| ALTER reports "Syntax error at or near 'REFRESH'" | `ALTER ... SET REFRESH INTERVAL` syntax does not exist | Use `CREATE OR REPLACE DYNAMIC TABLE ... REFRESH INTERVAL ...` to rebuild |
|
|
185
|
-
| ALTER reports "unsupported operation" | Attempted a Type B ALTER operation on a Dynamic Table | Use CREATE OR REPLACE to rebuild |
|
|
186
|
-
| `DROP TABLE dt_name` fails | Dynamic Tables must use `DROP DYNAMIC TABLE` | Change to `DROP DYNAMIC TABLE dt_name` |
|
|
187
|
-
| `UNDROP DYNAMIC TABLE` fails | UNDROP does not support the DYNAMIC TABLE keyword | Change to `UNDROP TABLE dt_name` |
|
|
188
|
-
| `DESC DYNAMIC TABLE ... EXTENDED` fails | EXTENDED parameter is not supported | Change to `DESC TABLE dt_name` (without EXTENDED) |
|
|
189
|
-
| UPDATE/DELETE reports "MV__KEY" related error | Dynamic Tables have a hidden column MV__KEY; DML is disabled by default | First execute `SET cz.sql.dt.allow.dml = true;` |
|
|
190
|
-
| Data is empty after CREATE OR REPLACE | The AS SELECT clause references an incorrect source table or column | Verify that the SELECT clause returns data first |
|
|
191
|
-
| Full refresh triggered after CREATE OR REPLACE | The new column participates in computation logic (JOIN key, GROUP key, etc.) | Expected behavior; wait for the full refresh to complete |
|