@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.
Files changed (69) hide show
  1. package/bin/cz-cli +0 -0
  2. package/bin/skills/clickzetta-ai-function/SKILL.md +109 -0
  3. package/bin/skills/clickzetta-ai-function/eval_cases.jsonl +4 -0
  4. package/bin/skills/clickzetta-ai-function/references/ai-function-ddl.md +106 -0
  5. package/bin/skills/clickzetta-batch-sync-pipeline/SKILL.md +124 -124
  6. package/bin/skills/clickzetta-batch-sync-pipeline/eval_cases.jsonl +5 -5
  7. package/bin/skills/clickzetta-bi-connect/SKILL.md +79 -78
  8. package/bin/skills/clickzetta-bi-connect/references/bi-tools.md +56 -56
  9. package/bin/skills/clickzetta-cdc-sync-pipeline/SKILL.md +386 -382
  10. package/bin/skills/clickzetta-cdc-sync-pipeline/eval_cases.jsonl +5 -5
  11. package/bin/skills/clickzetta-data-ingest-pipeline/SKILL.md +73 -212
  12. package/bin/skills/clickzetta-data-science/SKILL.md +57 -56
  13. package/bin/skills/clickzetta-data-science/references/bitmap-profile.md +38 -38
  14. package/bin/skills/clickzetta-data-science/references/data-patterns.md +16 -16
  15. package/bin/skills/clickzetta-data-science/references/setup.md +28 -28
  16. package/bin/skills/clickzetta-data-science/references/stats-functions.md +44 -44
  17. package/bin/skills/clickzetta-data-science/references/write-and-infer.md +22 -22
  18. package/bin/skills/clickzetta-data-science/references/zettapark-api.md +32 -32
  19. package/bin/skills/clickzetta-dw-modeling/SKILL.md +1 -1
  20. package/bin/skills/clickzetta-external-function/SKILL.md +51 -109
  21. package/bin/skills/clickzetta-external-function/eval_cases.jsonl +4 -4
  22. package/bin/skills/clickzetta-external-function/references/external-function-ddl.md +39 -77
  23. package/bin/skills/clickzetta-java-sdk/SKILL.md +49 -48
  24. package/bin/skills/clickzetta-java-sdk/eval_cases.jsonl +12 -12
  25. package/bin/skills/clickzetta-java-sdk/references/bulkload.md +34 -34
  26. package/bin/skills/clickzetta-java-sdk/references/realtime.md +44 -44
  27. package/bin/skills/clickzetta-kafka-ingest-pipeline/SKILL.md +273 -507
  28. package/bin/skills/clickzetta-kafka-ingest-pipeline/references/kafka-pipe-syntax.md +197 -231
  29. package/bin/skills/clickzetta-oss-ingest-pipeline/SKILL.md +231 -304
  30. package/bin/skills/clickzetta-realtime-sync-pipeline/SKILL.md +180 -179
  31. package/bin/skills/clickzetta-realtime-sync-pipeline/eval_cases.jsonl +5 -5
  32. package/bin/skills/clickzetta-semantic-view/SKILL.md +74 -72
  33. package/bin/skills/clickzetta-semantic-view/eval_cases.jsonl +12 -12
  34. package/bin/skills/clickzetta-semantic-view/references/semantic-view-reference.md +75 -75
  35. package/bin/skills/clickzetta-sql-migration/SKILL.md +128 -0
  36. package/bin/skills/clickzetta-sql-migration/eval_cases.jsonl +10 -0
  37. package/bin/skills/clickzetta-sql-migration/references/ddl-reference.md +350 -0
  38. package/bin/skills/clickzetta-sql-migration/references/dml-differences.md +192 -0
  39. package/bin/skills/clickzetta-sql-migration/references/dml-reference.md +279 -0
  40. package/bin/skills/{clickzetta-sql-syntax-guide → clickzetta-sql-migration}/references/dql-reference.md +128 -128
  41. package/bin/skills/clickzetta-sql-migration/references/function-mapping.md +194 -0
  42. package/bin/skills/clickzetta-sql-migration/references/functions-reference.md +372 -0
  43. package/bin/skills/clickzetta-sql-migration/references/implicit-type-conversion.md +143 -0
  44. package/bin/skills/clickzetta-sql-migration/references/migration-databricks.md +260 -0
  45. package/bin/skills/{clickzetta-sql-syntax-guide → clickzetta-sql-migration}/references/migration-snowflake.md +112 -112
  46. package/bin/skills/clickzetta-sql-migration/references/vs-snowflake.md +346 -0
  47. package/bin/skills/clickzetta-sql-migration/references/vs-spark.md +229 -0
  48. package/bin/skills/clickzetta-studio-task-manager/SKILL.md +326 -329
  49. package/bin/skills/clickzetta-table-lineage/SKILL.md +57 -55
  50. package/bin/skills/clickzetta-table-lineage/eval_cases.jsonl +1 -1
  51. package/bin/skills/clickzetta-table-lineage/references/normalize_func.sql +5 -5
  52. package/bin/skills/clickzetta-table-lineage/references/table_cost.sql +6 -6
  53. package/bin/skills/clickzetta-table-lineage/references/table_relation.sql +2 -2
  54. package/bin/skills/clickzetta-volume-manager/SKILL.md +186 -100
  55. package/bin/skills/clickzetta-volume-manager/references/volume-ddl.md +153 -52
  56. package/package.json +1 -1
  57. package/bin/skills/clickzetta-dynamic-table/best-practices/scheduling-guide.md +0 -135
  58. package/bin/skills/clickzetta-dynamic-table/dt-creator/references/dt-declaration-strategy.md +0 -185
  59. package/bin/skills/clickzetta-dynamic-table/dt-creator/references/refresh-history-guide.md +0 -260
  60. package/bin/skills/clickzetta-dynamic-table/dynamic-table-alter/SKILL.md +0 -191
  61. package/bin/skills/clickzetta-sql-syntax-guide/SKILL.md +0 -249
  62. package/bin/skills/clickzetta-sql-syntax-guide/eval_cases.jsonl +0 -3
  63. package/bin/skills/clickzetta-sql-syntax-guide/references/ddl-reference.md +0 -350
  64. package/bin/skills/clickzetta-sql-syntax-guide/references/dml-reference.md +0 -279
  65. package/bin/skills/clickzetta-sql-syntax-guide/references/functions-reference.md +0 -372
  66. package/bin/skills/clickzetta-sql-syntax-guide/references/migration-databricks.md +0 -260
  67. package/bin/skills/clickzetta-sql-syntax-guide/references/vs-snowflake.md +0 -346
  68. package/bin/skills/clickzetta-sql-syntax-guide/references/vs-spark.md +0 -229
  69. /package/bin/skills/{clickzetta-sql-syntax-guide → clickzetta-sql-migration}/LICENSE +0 -0
@@ -0,0 +1,279 @@
1
+ # DML Complete Syntax Reference
2
+
3
+ > Based on ClickZetta Lakehouse product documentation, with Snowflake / Spark SQL difference annotations
4
+
5
+ ---
6
+
7
+ ## ⚠️ Implicit Type Conversion Rules (Applies to INSERT / UPDATE)
8
+
9
+ **ClickZetta strictly prohibits implicit type conversion for write operations (INSERT/UPDATE); explicit CAST is required.**
10
+ However, implicit conversion is allowed in SELECT/WHERE/expressions.
11
+
12
+ ### Complete Rules Table (Verified)
13
+
14
+ | Target Column Type | Written Value | INSERT/UPDATE | WHERE/SELECT |
15
+ |---|---|---|---|
16
+ | `DATE` | `'2024-01-15'` (string) | ❌ Error | ✅ Allowed |
17
+ | `TIMESTAMP` | `'2024-01-15 12:00:00'` (string) | ❌ Error | ✅ Allowed |
18
+ | `BOOLEAN` | `'true'` / `'false'` (string) | ❌ Error | ✅ Allowed |
19
+ | `BOOLEAN` | `1` / `0` (integer) | ❌ Error | ✅ Allowed |
20
+ | `JSON` | `'{"k":1}'` (string) | ❌ Error | ✅ Allowed |
21
+ | `INT` / `BIGINT` | `'123'` (string) | ❌ Error | ✅ Allowed |
22
+ | `BIGINT` | `100` (INT) | ✅ Allowed | ✅ Allowed |
23
+ | `DOUBLE` | `1.5` (FLOAT) | ✅ Allowed | ✅ Allowed |
24
+ | `BIGINT` | `1.5` (FLOAT) | ✅ Allowed (truncated) | ✅ Allowed |
25
+
26
+ ### Correct Syntax for Each Type
27
+
28
+ ```sql
29
+ -- DATE (the following are equivalent)
30
+ INSERT INTO t VALUES (CAST('2024-01-15' AS DATE));
31
+ INSERT INTO t VALUES (DATE '2024-01-15');
32
+ INSERT INTO t VALUES (TO_DATE('2024-01-15'));
33
+ INSERT INTO t VALUES (DATE('2024-01-15')); -- function form, also supported
34
+
35
+ -- TIMESTAMP (the following are equivalent)
36
+ INSERT INTO t VALUES (CAST('2024-01-15 12:00:00' AS TIMESTAMP));
37
+ INSERT INTO t VALUES (TIMESTAMP '2024-01-15 12:00:00');
38
+ INSERT INTO t VALUES (TO_TIMESTAMP('2024-01-15 12:00:00'));
39
+ INSERT INTO t VALUES (TIMESTAMP('2024-01-15 12:00:00')); -- function form, also supported
40
+ INSERT INTO t VALUES (CURRENT_TIMESTAMP());
41
+ INSERT INTO t VALUES (CURRENT_DATE() - INTERVAL 7 DAY);
42
+
43
+ -- BOOLEAN (only accepts TRUE/FALSE literals or CAST)
44
+ INSERT INTO t VALUES (TRUE);
45
+ INSERT INTO t VALUES (FALSE);
46
+ INSERT INTO t VALUES (CAST(1 AS BOOLEAN));
47
+ INSERT INTO t VALUES (CAST('true' AS BOOLEAN));
48
+
49
+ -- JSON (must use PARSE_JSON or CAST)
50
+ INSERT INTO t VALUES (PARSE_JSON('{"key":"value"}'));
51
+ INSERT INTO t VALUES (CAST('{"key":"value"}' AS JSON));
52
+
53
+ -- INT/BIGINT (strings must be CAST)
54
+ INSERT INTO t VALUES (CAST('123' AS INT));
55
+ INSERT INTO t VALUES (CAST('456' AS BIGINT));
56
+ ```
57
+
58
+ ### UPDATE Has the Same Restrictions
59
+
60
+ ```sql
61
+ -- ❌ UPDATE also does not allow implicit string conversion
62
+ UPDATE orders SET dt = '2024-06-01' WHERE id = 1; -- Error
63
+ UPDATE orders SET flag = 0 WHERE id = 1; -- Error
64
+
65
+ -- ✅ Must explicitly convert
66
+ UPDATE orders SET dt = CAST('2024-06-01' AS DATE) WHERE id = 1;
67
+ UPDATE orders SET flag = CAST(0 AS BOOLEAN) WHERE id = 1;
68
+ ```
69
+
70
+ ### Strings Can Be Implicitly Compared in WHERE
71
+
72
+ ```sql
73
+ -- ✅ Strings can be compared with date/numeric in WHERE
74
+ SELECT * FROM orders WHERE dt = '2024-01-15';
75
+ SELECT * FROM orders WHERE dt >= '2024-01-01' AND dt < '2025-01-01';
76
+ SELECT * FROM orders WHERE id = '123';
77
+ ```
78
+
79
+ **Differences from Snowflake / Spark:**
80
+ - Snowflake / Spark: Strings can be implicitly converted to date/boolean/numeric types during INSERT/UPDATE
81
+ - ClickZetta: **Explicit conversion required** for writes, implicit comparison allowed in queries
82
+
83
+ > **Also applies to RESTORE TABLE**: `RESTORE TABLE t TO TIMESTAMP AS OF '2024-01-15'` will error; must use `CAST('2024-01-15 10:00:00' AS TIMESTAMP)` or a full millisecond timestamp string.
84
+
85
+ ---
86
+
87
+ ## INSERT
88
+
89
+ ```sql
90
+ -- Append (single row)
91
+ INSERT INTO orders VALUES (1, 101, 100.0, 'pending');
92
+ INSERT INTO orders (id, customer_id, amount) VALUES (1, 101, 100.0);
93
+
94
+ -- Append (multiple rows)
95
+ INSERT INTO orders VALUES
96
+ (1, 101, 100.0, 'pending'),
97
+ (2, 102, 200.0, 'completed');
98
+
99
+ -- Append from query
100
+ INSERT INTO orders SELECT * FROM staging_orders WHERE status = 'new';
101
+
102
+ -- Overwrite entire table
103
+ INSERT OVERWRITE TABLE orders SELECT * FROM new_orders;
104
+
105
+ -- Overwrite specific partition (static partition)
106
+ INSERT OVERWRITE TABLE orders PARTITION (dt = '2024-01-01')
107
+ SELECT id, amount FROM staging WHERE dt = '2024-01-01';
108
+
109
+ -- Dynamic partition (automatically partitions based on data values)
110
+ INSERT INTO orders PARTITION (dt)
111
+ SELECT id, amount, dt FROM staging;
112
+
113
+ -- Not recommended for large data volumes with VALUES; suitable for testing
114
+ ```
115
+
116
+ **Differences from Snowflake:**
117
+ - Snowflake has no `INSERT OVERWRITE`; use `TRUNCATE` + `INSERT` or `MERGE` instead
118
+ - Snowflake has no `PARTITION` clause (Snowflake uses CLUSTER BY for automatic management)
119
+ - ClickZetta supports Hive-style dynamic partitioning
120
+
121
+ **Differences from Spark SQL:**
122
+ - Syntax is basically the same; ClickZetta is fully compatible with Spark INSERT syntax
123
+
124
+ ---
125
+
126
+ ## UPDATE
127
+
128
+ ```sql
129
+ -- Basic update
130
+ UPDATE orders SET status = 'cancelled' WHERE id = 123;
131
+
132
+ -- Multi-column update
133
+ UPDATE orders
134
+ SET status = 'completed', updated_at = current_timestamp()
135
+ WHERE id = 123;
136
+
137
+ -- Subquery update
138
+ UPDATE orders
139
+ SET amount = amount * 1.1
140
+ WHERE customer_id IN (
141
+ SELECT id FROM customers WHERE tier = 'VIP'
142
+ );
143
+
144
+ -- With ORDER BY + LIMIT (batch update)
145
+ UPDATE orders
146
+ SET status = 'archived'
147
+ WHERE created_at < '2020-01-01'
148
+ ORDER BY created_at ASC
149
+ LIMIT 10000;
150
+ ```
151
+
152
+ **Differences from Snowflake:**
153
+ - Snowflake `UPDATE ... FROM` syntax (JOIN update) → ClickZetta uses subquery instead
154
+ - ClickZetta additionally supports `ORDER BY + LIMIT` (Snowflake does not)
155
+
156
+ **Differences from Spark SQL:**
157
+ - Spark SQL does not support `UPDATE` (Delta Lake does); ClickZetta natively supports it
158
+
159
+ ---
160
+
161
+ ## DELETE
162
+
163
+ ```sql
164
+ -- Basic delete
165
+ DELETE FROM orders WHERE id = 123;
166
+
167
+ -- Conditional delete
168
+ DELETE FROM orders WHERE created_at < '2020-01-01';
169
+
170
+ -- Subquery delete
171
+ DELETE FROM orders
172
+ WHERE order_id IN (
173
+ SELECT order_id FROM order_details WHERE status = 'cancelled'
174
+ );
175
+
176
+ -- Delete all rows (equivalent to TRUNCATE, but records version)
177
+ DELETE FROM orders WHERE 1 = 1;
178
+ ```
179
+
180
+ **Differences from Snowflake:**
181
+ - Syntax is basically the same
182
+
183
+ **Differences from Spark SQL:**
184
+ - Spark SQL does not support `DELETE` (Delta Lake does); ClickZetta natively supports it
185
+
186
+ ---
187
+
188
+ ## MERGE INTO (UPSERT)
189
+
190
+ ```sql
191
+ -- Standard MERGE (⚠️ when multiple WHEN MATCHED clauses, UPDATE must come before DELETE)
192
+ MERGE INTO target t
193
+ USING source s ON t.id = s.id
194
+ WHEN MATCHED AND s.is_deleted = 0 THEN UPDATE SET -- UPDATE first
195
+ t.amount = s.amount,
196
+ t.status = s.status,
197
+ t.updated_at = current_timestamp()
198
+ WHEN MATCHED AND s.is_deleted = 1 THEN DELETE -- DELETE second
199
+ WHEN NOT MATCHED THEN INSERT (id, amount, status, created_at)
200
+ VALUES (s.id, s.amount, s.status, current_timestamp());
201
+
202
+ -- Multiple WHEN MATCHED (UPDATE must come before DELETE)
203
+ MERGE INTO target t
204
+ USING source s ON t.id = s.id
205
+ WHEN MATCHED AND s.action = 'update' THEN UPDATE SET t.amount = s.amount
206
+ WHEN MATCHED AND s.action = 'delete' THEN DELETE
207
+ WHEN NOT MATCHED THEN INSERT VALUES (s.id, s.amount);
208
+
209
+ -- MERGE from subquery
210
+ MERGE INTO orders t
211
+ USING (
212
+ SELECT id, SUM(amount) AS total FROM line_items GROUP BY id
213
+ ) s ON t.id = s.id
214
+ WHEN MATCHED THEN UPDATE SET t.total = s.total
215
+ WHEN NOT MATCHED THEN INSERT (id, total) VALUES (s.id, s.total);
216
+ ```
217
+
218
+ **⚠️ ClickZetta MERGE Limitations:**
219
+ 1. `WHEN NOT MATCHED` can only appear **once** (Snowflake supports multiple)
220
+ 2. When multiple `WHEN MATCHED` clauses exist, `UPDATE` must come before `DELETE`
221
+ 3. A single source row cannot match multiple target rows (otherwise errors)
222
+
223
+ **Differences from Snowflake:**
224
+ - Snowflake supports multiple `WHEN NOT MATCHED`; ClickZetta only supports one
225
+ - Snowflake `MERGE ... WHEN NOT MATCHED BY SOURCE THEN DELETE`; ClickZetta does not support
226
+ - Syntax structure is basically the same
227
+
228
+ **Differences from Spark SQL:**
229
+ - Spark SQL (Delta Lake) supports `WHEN NOT MATCHED BY SOURCE`; ClickZetta does not support
230
+ - Syntax structure is basically the same
231
+
232
+ ---
233
+
234
+ ## COPY INTO (Bulk Import/Export)
235
+
236
+ ```sql
237
+ -- Import from Volume
238
+ COPY INTO orders
239
+ FROM VOLUME my_oss_volume
240
+ USING CSV
241
+ OPTIONS('header' = 'true', 'sep' = ',')
242
+ SUBDIRECTORY 'data/2024/';
243
+
244
+ -- Import from Volume (Parquet)
245
+ COPY INTO orders
246
+ FROM VOLUME my_oss_volume
247
+ USING PARQUET
248
+ FILES('part-00001.parquet', 'part-00002.parquet');
249
+
250
+ -- Regex file matching
251
+ COPY INTO orders
252
+ FROM VOLUME my_oss_volume
253
+ USING PARQUET
254
+ REGEXP '.*2024-0[1-6].parquet';
255
+
256
+ -- Overwrite import
257
+ COPY OVERWRITE INTO orders
258
+ FROM VOLUME my_oss_volume
259
+ USING CSV OPTIONS('header' = 'true');
260
+
261
+ -- Export to Volume
262
+ COPY INTO VOLUME my_oss_volume
263
+ SUBDIRECTORY 'export/orders/'
264
+ FROM orders
265
+ USING PARQUET;
266
+
267
+ -- Export query results
268
+ COPY INTO VOLUME my_oss_volume
269
+ SUBDIRECTORY 'export/2024/'
270
+ FROM (SELECT * FROM orders WHERE YEAR(created_at) = 2024)
271
+ USING CSV OPTIONS('header' = 'true');
272
+ ```
273
+
274
+ **Differences from Snowflake:**
275
+ - Snowflake `COPY INTO t FROM @stage/path/file.csv` → ClickZetta `COPY INTO t FROM VOLUME v USING CSV`
276
+ - Snowflake Stage uses `@` prefix; ClickZetta Volume uses object name
277
+ - Snowflake `COPY INTO @stage FROM t` → ClickZetta `COPY INTO VOLUME v FROM t`
278
+ - Snowflake supports `PATTERN = '.*\.csv'`; ClickZetta uses `REGEXP`
279
+ - Snowflake `FILE_FORMAT = (TYPE = CSV)` → ClickZetta `USING CSV OPTIONS(...)`