@clickzetta/cz-cli-darwin-x64 0.3.92 → 0.3.94

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
@@ -1,79 +1,81 @@
1
1
  ---
2
2
  name: clickzetta-semantic-view
3
3
  description: |
4
- 创建和查询 ClickZetta Lakehouse 语义视图(Semantic View)。语义视图是架构级逻辑
5
- 数据模型对象,通过声明逻辑表、维度、指标、过滤器,将复杂的多表 JOIN 和聚合逻辑封装
6
- 为业务友好的语义层,使用 semantic_view() 函数查询,无需手写 JOIN。
7
- 当前为邀测功能(1.3 版本起)。
8
- 当用户说"创建语义视图"、"semantic view"、"语义层"、"定义指标"、"定义维度"、
9
- "semantic_view() 怎么用""统一指标口径""业务语义模型"、"逻辑表"、
10
- "DIMENSIONS""METRICS""FILTERS"、"DROP SEMANTIC VIEW"
11
- "SHOW SEMANTIC VIEWS"时触发。
4
+ Create and query ClickZetta Lakehouse Semantic Views. A Semantic View is a schema-level logical
5
+ data model object that encapsulates complex multi-table JOINs and aggregation logic into a
6
+ business-friendly semantic layer by declaring logical tables, dimensions, metrics, and filters.
7
+ Query using the semantic_view() function without writing JOINs manually.
8
+ Currently in invite-only preview (since version 1.3).
9
+ Triggered when user says "create semantic view", "semantic view", "semantic layer",
10
+ "define metrics", "define dimensions", "how to use semantic_view()",
11
+ "unified metric definitions", "business semantic model", "logical table",
12
+ "DIMENSIONS", "METRICS", "FILTERS", "DROP SEMANTIC VIEW",
13
+ "SHOW SEMANTIC VIEWS".
12
14
  Keywords: semantic view, dimension, metric, logical model, unified metrics, semantic layer
13
15
  ---
14
16
 
15
- # ClickZetta 语义视图(Semantic View
17
+ # ClickZetta Semantic View
16
18
 
17
- 阅读 [references/semantic-view-reference.md](references/semantic-view-reference.md) 了解完整语法。
19
+ Read [references/semantic-view-reference.md](references/semantic-view-reference.md) for the complete syntax reference.
18
20
 
19
21
  ---
20
22
 
21
- ## 概述
23
+ ## Overview
22
24
 
23
- 语义视图是 ClickZetta Lakehouse 的**架构级逻辑数据模型对象**,解决两类核心问题:
25
+ A Semantic View is a **schema-level logical data model object** in ClickZetta Lakehouse that solves two core problems:
24
26
 
25
- - **数据分析**:统一维度和指标定义,业务用户无需编写复杂 JOIN 即可查询跨表数据
26
- - **数据治理**:集中管理表关系、维度、指标定义,确保全组织使用相同数据口径
27
+ - **Data Analysis**: Unifies dimension and metric definitions so business users can query cross-table data without writing complex JOINs
28
+ - **Data Governance**: Centrally manages table relationships, dimension and metric definitions, ensuring the entire organization uses consistent data definitions
27
29
 
28
- > ⚠️ 当前为**邀测功能**(1.3 版本),需联系技术支持开通。
30
+ > ⚠️ Currently in **invite-only preview** (version 1.3). Contact technical support to enable.
29
31
 
30
32
  ---
31
33
 
32
- ## 四大组件
34
+ ## Four Core Components
33
35
 
34
- | 组件 | 关键字 | 说明 |
36
+ | Component | Keyword | Description |
35
37
  |---|---|---|
36
- | 逻辑表 | `TABLES` | 映射物理表,声明主键和外键关系,引擎自动处理 JOIN |
37
- | 维度 | `DIMENSIONS` | 分类属性(谁/什么/哪里/何时),支持计算维度 |
38
- | 指标 | `METRICS` | 聚合度量(SUM/AVG/COUNT/MIN/MAX),业务 KPI |
39
- | 过滤器 | `FILTERS` | 预定义可重用过滤条件(语义注解,不可直接传入查询) |
38
+ | Logical Tables | `TABLES` | Maps physical tables, declares primary and foreign key relationships; the engine handles JOINs automatically |
39
+ | Dimensions | `DIMENSIONS` | Categorical attributes (who/what/where/when), supports computed dimensions |
40
+ | Metrics | `METRICS` | Aggregate measures (SUM/AVG/COUNT/MIN/MAX), business KPIs |
41
+ | Filters | `FILTERS` | Predefined reusable filter conditions (semantic annotations, cannot be passed directly to queries) |
40
42
 
41
43
  ---
42
44
 
43
- ## 创建语义视图
45
+ ## Creating a Semantic View
44
46
 
45
47
  ```sql
46
- CREATE SEMANTIC VIEW <视图名>
48
+ CREATE SEMANTIC VIEW <view_name>
47
49
  TABLES (
48
- <表别名> AS <schema>.<物理表>
49
- PRIMARY KEY (<列名>)
50
- [ FOREIGN KEY (<列名>) REFERENCES <其他表别名> ]
51
- [ WITH SYNONYMS ('<同义词>') ]
52
- [ COMMENT = '<说明>' ]
50
+ <table_alias> AS <schema>.<physical_table>
51
+ PRIMARY KEY (<column_name>)
52
+ [ FOREIGN KEY (<column_name>) REFERENCES <other_table_alias> ]
53
+ [ WITH SYNONYMS ('<synonym>') ]
54
+ [ COMMENT = '<description>' ]
53
55
  [ , ... ]
54
56
  )
55
57
  [ FILTERS (
56
- <表别名>.<过滤器名> AS <布尔表达式>
58
+ <table_alias>.<filter_name> AS <boolean_expression>
57
59
  [ , ... ]
58
60
  ) ]
59
61
  DIMENSIONS (
60
- { <表别名>.<维度名> | <维度名> } AS <表达式>
61
- [ WITH SYNONYMS = ('<同义词>' [ , ... ]) ]
62
+ { <table_alias>.<dimension_name> | <dimension_name> } AS <expression>
63
+ [ WITH SYNONYMS = ('<synonym>' [ , ... ]) ]
62
64
  [ is_unique = { true | false } ]
63
65
  [ is_time = { true | false } ]
64
- [ enum_values = [ <值1>, <值2>, ... ] ]
65
- [ COMMENT = '<说明>' ]
66
+ [ enum_values = [ <value1>, <value2>, ... ] ]
67
+ [ COMMENT = '<description>' ]
66
68
  [ , ... ]
67
69
  )
68
70
  METRICS (
69
- <表别名>.<指标名> AS <聚合表达式>
70
- [ COMMENT = '<说明>' ]
71
+ <table_alias>.<metric_name> AS <aggregate_expression>
72
+ [ COMMENT = '<description>' ]
71
73
  [ , ... ]
72
74
  )
73
- [ COMMENT = '<视图说明>' ];
75
+ [ COMMENT = '<view_description>' ];
74
76
  ```
75
77
 
76
- ### 完整示例(TPC-H 收入分析)
78
+ ### Complete Example (TPC-H Revenue Analysis)
77
79
 
78
80
  ```sql
79
81
  DROP SEMANTIC VIEW IF EXISTS tpch_rev_analysis;
@@ -81,60 +83,60 @@ CREATE SEMANTIC VIEW tpch_rev_analysis
81
83
  TABLES (
82
84
  customers AS tpch.customer
83
85
  PRIMARY KEY (c_custkey)
84
- COMMENT = '客户主表',
86
+ COMMENT = 'Customer master table',
85
87
  orders AS tpch.orders
86
88
  PRIMARY KEY (o_orderkey)
87
89
  FOREIGN KEY (o_custkey) REFERENCES customers
88
- WITH SYNONYMS ('销售订单')
89
- COMMENT = '订单表',
90
+ WITH SYNONYMS ('sales orders')
91
+ COMMENT = 'Orders table',
90
92
  line_items AS tpch.lineitem
91
93
  PRIMARY KEY (l_orderkey, l_linenumber)
92
94
  FOREIGN KEY (l_orderkey) REFERENCES orders
93
- COMMENT = '订单明细'
95
+ COMMENT = 'Order line items'
94
96
  )
95
97
  FILTERS (
96
98
  customers.is_building AS customers.c_mktsegment = 'BUILDING'
97
99
  )
98
100
  DIMENSIONS (
99
101
  customers.customer_name AS c_name
100
- WITH SYNONYMS = ('客户名称', 'customer name')
102
+ WITH SYNONYMS = ('customer name')
101
103
  is_unique = true
102
- COMMENT = '客户名称',
104
+ COMMENT = 'Customer name',
103
105
  orders.order_date AS o_orderdate
104
106
  is_time = true
105
- COMMENT = '下单日期',
107
+ COMMENT = 'Order date',
106
108
  orders.order_year AS YEAR(o_orderdate)
107
- COMMENT = '下单年份',
109
+ COMMENT = 'Order year',
108
110
  orders.order_status AS o_orderstatus
109
111
  enum_values = ['O', 'F', 'P']
110
- COMMENT = '订单状态'
112
+ COMMENT = 'Order status'
111
113
  )
112
114
  METRICS (
113
115
  customers.customer_count AS COUNT(c_custkey)
114
- COMMENT = '客户总数',
116
+ COMMENT = 'Total customer count',
115
117
  orders.avg_order_value AS AVG(o_totalprice)
116
- COMMENT = '平均订单金额',
118
+ COMMENT = 'Average order value',
117
119
  orders.total_revenue AS SUM(o_totalprice)
118
- COMMENT = '总收入'
120
+ COMMENT = 'Total revenue'
119
121
  )
120
- COMMENT = '收入分析语义视图';
122
+ COMMENT = 'Revenue analysis semantic view';
121
123
  ```
122
124
 
123
125
  ---
124
126
 
125
- ## 查询语义视图
127
+ ## Querying a Semantic View
126
128
 
127
- 使用 `semantic_view()` 表函数,**无需手写 JOIN GROUP BY**:
129
+ Use the `semantic_view()` table function **no need to write JOINs or GROUP BY manually**:
128
130
 
129
131
  ```sql
130
- -- 基础查询:按订单日期统计平均订单金额
132
+ -- Basic query: average order value by order date
131
133
  SELECT * FROM semantic_view(
132
134
  tpch_rev_analysis,
133
135
  DIMENSIONS orders.order_date,
134
136
  METRICS orders.avg_order_value
135
137
  );
136
138
 
137
- -- 多维度查询:按日期和客户名称
139
+ -- Multi-dimension query: by date and customer name
138
140
  SELECT * FROM semantic_view(
139
141
  tpch_rev_analysis,
140
142
  DIMENSIONS orders.order_date,
@@ -142,7 +144,7 @@ SELECT * FROM semantic_view(
142
144
  METRICS orders.avg_order_value
143
145
  );
144
146
 
145
- -- 使用短名称(名称唯一时可省略表别名前缀)
147
+ -- Using short names (table alias prefix can be omitted when names are unique)
146
148
  SELECT * FROM semantic_view(
147
149
  tpch_rev_analysis,
148
150
  DIMENSIONS order_date,
@@ -150,7 +152,7 @@ SELECT * FROM semantic_view(
150
152
  METRICS avg_order_value
151
153
  );
152
154
 
153
- -- WHERE 过滤(需将过滤列定义为 DIMENSION)
155
+ -- Adding WHERE filter (filter columns must be defined as DIMENSIONS)
154
156
  SELECT * FROM semantic_view(
155
157
  tpch_rev_analysis,
156
158
  DIMENSIONS customers.customer_name,
@@ -159,16 +161,16 @@ SELECT * FROM semantic_view(
159
161
  ) WHERE order_status = 'O';
160
162
  ```
161
163
 
162
- ### 与传统 SQL 对比
164
+ ### Comparison with Traditional SQL
163
165
 
164
166
  ```sql
165
- -- 传统 SQL(需手写 JOIN + GROUP BY
167
+ -- Traditional SQL (requires manual JOIN + GROUP BY)
166
168
  SELECT o.o_orderdate, c.c_name, AVG(o.o_totalprice)
167
169
  FROM tpch.orders o
168
170
  JOIN tpch.customer c ON o.o_custkey = c.c_custkey
169
171
  GROUP BY o.o_orderdate, c.c_name;
170
172
 
171
- -- 语义视图(自动处理 JOIN 和聚合)
173
+ -- Semantic View (JOINs and aggregation handled automatically)
172
174
  SELECT * FROM semantic_view(
173
175
  tpch_rev_analysis,
174
176
  DIMENSIONS order_date,
@@ -179,29 +181,29 @@ SELECT * FROM semantic_view(
179
181
 
180
182
  ---
181
183
 
182
- ## 管理命令
184
+ ## Management Commands
183
185
 
184
186
  ```sql
185
- -- 删除(推荐先删再建,确保幂等)
187
+ -- Drop (recommended: drop before create for idempotency)
186
188
  DROP SEMANTIC VIEW IF EXISTS tpch_rev_analysis;
187
189
 
188
- -- 列出当前 Schema 的所有语义视图
190
+ -- List all semantic views in the current schema
189
191
  SHOW SEMANTIC VIEWS;
190
192
  SHOW SEMANTIC VIEWS IN my_schema;
191
193
 
192
- -- 查看详细定义(逻辑表、维度、指标、外键)
194
+ -- View detailed definition (logical tables, dimensions, metrics, foreign keys)
193
195
  DESC EXTENDED tpch_rev_analysis;
194
196
  ```
195
197
 
196
198
  ---
197
199
 
198
- ## 注意事项
200
+ ## Important Notes
199
201
 
200
- 1. **TABLES 定义顺序**:被外键引用的表必须先定义(如 `customers` 必须在 `orders` 之前)
201
- 2. **FILTERS 是语义注解**:`FILTERS` 中的命名过滤器不能作为 `semantic_view()` 的参数,WHERE 子句只能引用 `DIMENSIONS` 中定义的列名(短名),不能用物理列名
202
- 3. **WHERE 只能用 DIMENSION 短名**:`WHERE customer_name = 'Alice'` ✅,`WHERE c_name = 'Alice'` ❌
203
- 4. **短名称 vs 限定名称**:名称在视图内唯一时可用短名称,有冲突时必须用 `表别名.名称`
204
- 5. **幂等创建**:始终先 `DROP SEMANTIC VIEW IF EXISTS` 再创建,避免重复执行报错
205
- 6. **计算维度**:DIMENSIONS 支持表达式,如 `YEAR(CAST(order_date AS DATE))` 提取年份
206
- 7. **指标聚合函数**:仅支持 `COUNT`、`AVG`、`SUM`、`MIN`、`MAX`
207
- 8. **DIMENSIONS METRICS 可单独使用**:可以只查 METRICS(全局聚合),也可以只查 DIMENSIONS(去重列表)
202
+ 1. **TABLES definition order**: Tables referenced by foreign keys must be defined first (e.g., `customers` must come before `orders`)
203
+ 2. **FILTERS are semantic annotations**: Named filters in `FILTERS` cannot be passed as parameters to `semantic_view()`; WHERE clauses can only reference column short names defined in `DIMENSIONS`, not physical column names
204
+ 3. **WHERE only accepts DIMENSION short names**: `WHERE customer_name = 'Alice'` ✅, `WHERE c_name = 'Alice'` ❌
205
+ 4. **Short names vs qualified names**: Use short names when unique within the view; use `table_alias.name` when there are conflicts
206
+ 5. **Idempotent creation**: Always `DROP SEMANTIC VIEW IF EXISTS` before creating to avoid errors on repeated execution
207
+ 6. **Computed dimensions**: DIMENSIONS supports expressions, e.g., `YEAR(CAST(order_date AS DATE))` to extract year
208
+ 7. **Metric aggregate functions**: Only `COUNT`, `AVG`, `SUM`, `MIN`, `MAX` are supported
209
+ 8. **DIMENSIONS and METRICS can be used independently**: You can query only METRICS (global aggregation) or only DIMENSIONS (deduplicated list)
@@ -1,12 +1,12 @@
1
- {"case_id":"001","type":"should_call","user_input":"怎么创建语义视图","expected_skill":"clickzetta-semantic-view","expected_output_contains":["CREATE SEMANTIC VIEW"]}
2
- {"case_id":"002","type":"should_call","user_input":"semantic_view() 函数怎么查询","expected_skill":"clickzetta-semantic-view","expected_output_contains":["semantic_view"]}
3
- {"case_id":"003","type":"should_call","user_input":"语义视图里怎么定义维度和指标","expected_skill":"clickzetta-semantic-view","expected_output_contains":["DIMENSIONS","METRICS"]}
4
- {"case_id":"004","type":"should_call","user_input":"怎么用语义层统一指标口径","expected_skill":"clickzetta-semantic-view","expected_output_contains":["语义"]}
5
- {"case_id":"005","type":"should_call","user_input":"SHOW SEMANTIC VIEWS 怎么用","expected_skill":"clickzetta-semantic-view","expected_output_contains":["SHOW SEMANTIC VIEWS"]}
6
- {"case_id":"006","type":"should_call","user_input":"语义视图的 FILTERS 怎么定义","expected_skill":"clickzetta-semantic-view","expected_output_contains":["FILTERS"]}
7
- {"case_id":"007","type":"should_call","user_input":"DROP SEMANTIC VIEW 怎么删除","expected_skill":"clickzetta-semantic-view","expected_output_contains":["DROP SEMANTIC VIEW"]}
8
- {"case_id":"008","type":"should_not_call","user_input":"怎么创建普通视图","forbidden_skill":"clickzetta-semantic-view"}
9
- {"case_id":"009","type":"should_not_call","user_input":"帮我写一个数据看板","forbidden_skill":"clickzetta-semantic-view"}
10
- {"case_id":"010","type":"should_not_call","user_input":"怎么做数据建模","forbidden_skill":"clickzetta-semantic-view"}
11
- {"case_id":"011","type":"should_not_call","user_input":"Superset 怎么连接","forbidden_skill":"clickzetta-semantic-view"}
12
- {"case_id":"012","type":"should_not_call","user_input":"怎么创建物化视图","forbidden_skill":"clickzetta-semantic-view"}
1
+ {"case_id":"001","type":"should_call","user_input":"How to create a semantic view","expected_skill":"clickzetta-semantic-view","expected_output_contains":["CREATE SEMANTIC VIEW"]}
2
+ {"case_id":"002","type":"should_call","user_input":"How to query with semantic_view() function","expected_skill":"clickzetta-semantic-view","expected_output_contains":["semantic_view"]}
3
+ {"case_id":"003","type":"should_call","user_input":"How to define dimensions and metrics in a semantic view","expected_skill":"clickzetta-semantic-view","expected_output_contains":["DIMENSIONS","METRICS"]}
4
+ {"case_id":"004","type":"should_call","user_input":"How to use the semantic layer to unify metric definitions","expected_skill":"clickzetta-semantic-view","expected_output_contains":["semantic"]}
5
+ {"case_id":"005","type":"should_call","user_input":"How to use SHOW SEMANTIC VIEWS","expected_skill":"clickzetta-semantic-view","expected_output_contains":["SHOW SEMANTIC VIEWS"]}
6
+ {"case_id":"006","type":"should_call","user_input":"How to define FILTERS in a semantic view","expected_skill":"clickzetta-semantic-view","expected_output_contains":["FILTERS"]}
7
+ {"case_id":"007","type":"should_call","user_input":"How to drop a semantic view with DROP SEMANTIC VIEW","expected_skill":"clickzetta-semantic-view","expected_output_contains":["DROP SEMANTIC VIEW"]}
8
+ {"case_id":"008","type":"should_not_call","user_input":"How to create a regular view","forbidden_skill":"clickzetta-semantic-view"}
9
+ {"case_id":"009","type":"should_not_call","user_input":"Help me build a data dashboard","forbidden_skill":"clickzetta-semantic-view"}
10
+ {"case_id":"010","type":"should_not_call","user_input":"How to do data modeling","forbidden_skill":"clickzetta-semantic-view"}
11
+ {"case_id":"011","type":"should_not_call","user_input":"How to connect Superset","forbidden_skill":"clickzetta-semantic-view"}
12
+ {"case_id":"012","type":"should_not_call","user_input":"How to create a materialized view","forbidden_skill":"clickzetta-semantic-view"}
@@ -1,61 +1,61 @@
1
- # 语义视图完整语法参考
1
+ # Semantic View Complete Syntax Reference
2
2
 
3
- > 来源:https://www.yunqi.tech/documents/semantic_view
4
- > 功能状态:邀测(1.3 版本起)
3
+ > Source: https://www.yunqi.tech/documents/semantic_view
4
+ > Feature status: Invite-only preview (since version 1.3)
5
5
 
6
6
  ---
7
7
 
8
- ## CREATE SEMANTIC VIEW 完整语法
8
+ ## CREATE SEMANTIC VIEW Full Syntax
9
9
 
10
10
  ```sql
11
- CREATE SEMANTIC VIEW <视图名称>
11
+ CREATE SEMANTIC VIEW <view_name>
12
12
  TABLES (
13
- <逻辑表定义> [ , ... ]
13
+ <logical_table_definition> [ , ... ]
14
14
  )
15
15
  [ FILTERS (
16
- <过滤器定义> [ , ... ]
16
+ <filter_definition> [ , ... ]
17
17
  ) ]
18
18
  DIMENSIONS (
19
- <维度定义> [ , ... ]
19
+ <dimension_definition> [ , ... ]
20
20
  )
21
21
  METRICS (
22
- <指标定义> [ , ... ]
22
+ <metric_definition> [ , ... ]
23
23
  )
24
- [ COMMENT = '<视图说明>' ];
24
+ [ COMMENT = '<view_description>' ];
25
25
  ```
26
26
 
27
- **约束**:`DIMENSIONS` `METRICS` 至少包含其中一个。
27
+ **Constraint**: At least one of `DIMENSIONS` or `METRICS` must be included.
28
28
 
29
29
  ---
30
30
 
31
- ## 逻辑表定义语法
31
+ ## Logical Table Definition Syntax
32
32
 
33
33
  ```sql
34
- <表别名> AS <schema>.<物理表名>
35
- PRIMARY KEY ( <列名> [ , ... ] )
36
- [ FOREIGN KEY ( <列名> ) REFERENCES <其他逻辑表别名> ]
37
- [ WITH SYNONYMS ( '<同义词>' [ , ... ] ) ]
38
- [ COMMENT = '<说明>' ]
34
+ <table_alias> AS <schema>.<physical_table_name>
35
+ PRIMARY KEY ( <column_name> [ , ... ] )
36
+ [ FOREIGN KEY ( <column_name> ) REFERENCES <other_logical_table_alias> ]
37
+ [ WITH SYNONYMS ( '<synonym>' [ , ... ] ) ]
38
+ [ COMMENT = '<description>' ]
39
39
  ```
40
40
 
41
- | 参数 | 说明 |
41
+ | Parameter | Description |
42
42
  |---|---|
43
- | `<表别名> AS <schema>.<物理表>` | 为物理表指定逻辑别名,后续维度/指标/外键均用此别名引用 |
44
- | `PRIMARY KEY` | 主键列,用于确定表间关系类型(一对多/一对一) |
45
- | `FOREIGN KEY ... REFERENCES` | 外键关系,引擎据此自动处理 JOIN;引用目标必须是逻辑表别名 |
46
- | `WITH SYNONYMS` | 逻辑表同义词,增强可发现性 |
43
+ | `<table_alias> AS <schema>.<physical_table>` | Assigns a logical alias to a physical table; dimensions/metrics/foreign keys reference this alias |
44
+ | `PRIMARY KEY` | Primary key columns, used to determine relationship types between tables (one-to-many/one-to-one) |
45
+ | `FOREIGN KEY ... REFERENCES` | Foreign key relationship; the engine uses this to handle JOINs automatically; target must be a logical table alias |
46
+ | `WITH SYNONYMS` | Logical table synonyms to enhance discoverability |
47
47
 
48
- **注意**:被外键引用的表必须在 TABLES 子句中先定义。
48
+ **Note**: Tables referenced by foreign keys must be defined first in the TABLES clause.
49
49
 
50
50
  ---
51
51
 
52
- ## 过滤器定义语法
52
+ ## Filter Definition Syntax
53
53
 
54
54
  ```sql
55
- <逻辑表别名>.<过滤器名> AS <布尔表达式>
55
+ <logical_table_alias>.<filter_name> AS <boolean_expression>
56
56
  ```
57
57
 
58
- 示例:
58
+ Example:
59
59
  ```sql
60
60
  FILTERS (
61
61
  customers.is_building AS customers.c_mktsegment = 'BUILDING',
@@ -63,105 +63,105 @@ FILTERS (
63
63
  )
64
64
  ```
65
65
 
66
- **重要**:FILTERS 是面向 AI/元数据层的语义注解,**不能**作为 `semantic_view()` 函数参数直接传入。若要在查询中过滤,需将对应列定义为 DIMENSION,再用外层 WHERE 子句。
66
+ **Important**: FILTERS are semantic annotations for AI/metadata layers and **cannot** be passed directly as parameters to the `semantic_view()` function. To filter in queries, define the corresponding column as a DIMENSION and use an outer WHERE clause.
67
67
 
68
68
  ---
69
69
 
70
- ## 维度定义语法
70
+ ## Dimension Definition Syntax
71
71
 
72
72
  ```sql
73
- { <逻辑表别名>.<维度名> | <维度名> } AS <表达式>
74
- [ WITH SYNONYMS = ( '<同义词>' [ , ... ] ) ]
73
+ { <logical_table_alias>.<dimension_name> | <dimension_name> } AS <expression>
74
+ [ WITH SYNONYMS = ( '<synonym>' [ , ... ] ) ]
75
75
  [ is_unique = { true | false } ]
76
76
  [ is_time = { true | false } ]
77
- [ enum_values = [ <值1>, <值2>, ... ] ]
78
- [ COMMENT = '<说明>' ]
77
+ [ enum_values = [ <value1>, <value2>, ... ] ]
78
+ [ COMMENT = '<description>' ]
79
79
  ```
80
80
 
81
- | 参数 | 说明 |
81
+ | Parameter | Description |
82
82
  |---|---|
83
- | `AS <表达式>` | 可以是列名,也可以是计算表达式(如 `YEAR(o_orderdate)`) |
84
- | `WITH SYNONYMS` | 维度同义词,用户可用不同业务术语引用同一维度 |
85
- | `is_unique = true` | 标识该维度值唯一(如客户名称),帮助引擎优化 |
86
- | `is_time = true` | 标识为时间类型维度(如订单日期) |
87
- | `enum_values` | 限定允许的枚举值,提升查询准确性 |
83
+ | `AS <expression>` | Can be a column name or a computed expression (e.g., `YEAR(o_orderdate)`) |
84
+ | `WITH SYNONYMS` | Dimension synonyms allowing users to reference the same dimension with different business terms |
85
+ | `is_unique = true` | Indicates the dimension values are unique (e.g., customer name), helps the engine optimize |
86
+ | `is_time = true` | Identifies as a time-type dimension (e.g., order date) |
87
+ | `enum_values` | Restricts allowed enumeration values, improves query accuracy |
88
88
 
89
89
  ---
90
90
 
91
- ## 指标定义语法
91
+ ## Metric Definition Syntax
92
92
 
93
93
  ```sql
94
- <逻辑表别名>.<指标名> AS <聚合表达式>
95
- [ COMMENT = '<说明>' ]
94
+ <logical_table_alias>.<metric_name> AS <aggregate_expression>
95
+ [ COMMENT = '<description>' ]
96
96
  ```
97
97
 
98
- 支持的聚合函数:`COUNT`、`AVG`、`SUM`、`MIN`、`MAX`
98
+ Supported aggregate functions: `COUNT`, `AVG`, `SUM`, `MIN`, `MAX`
99
99
 
100
- 示例:
100
+ Example:
101
101
  ```sql
102
102
  METRICS (
103
103
  orders.total_revenue AS SUM(o_totalprice)
104
- COMMENT = '总收入',
104
+ COMMENT = 'Total revenue',
105
105
  orders.avg_order_value AS AVG(o_totalprice)
106
- COMMENT = '平均订单金额',
106
+ COMMENT = 'Average order value',
107
107
  customers.customer_count AS COUNT(c_custkey)
108
- COMMENT = '客户总数'
108
+ COMMENT = 'Total customer count'
109
109
  )
110
110
  ```
111
111
 
112
112
  ---
113
113
 
114
- ## semantic_view() 查询函数语法
114
+ ## semantic_view() Query Function Syntax
115
115
 
116
116
  ```sql
117
117
  SELECT *
118
118
  FROM semantic_view(
119
- <视图名称>,
120
- DIMENSIONS <维度名> [ , DIMENSIONS <维度名> ... ],
121
- METRICS <指标名> [ , METRICS <指标名> ... ]
119
+ <view_name>,
120
+ DIMENSIONS <dimension_name> [ , DIMENSIONS <dimension_name> ... ],
121
+ METRICS <metric_name> [ , METRICS <metric_name> ... ]
122
122
  )
123
- [ WHERE <过滤条件> ];
123
+ [ WHERE <filter_condition> ];
124
124
  ```
125
125
 
126
- - 维度名可用限定名(`表别名.维度名`)或短名(名称唯一时)
127
- - 结果自动按指定维度分组,无需写 GROUP BY
128
- - WHERE 子句中的列名使用短名(不含表别名前缀)
126
+ - Dimension names can use qualified names (`table_alias.dimension_name`) or short names (when unique)
127
+ - Results are automatically grouped by specified dimensions — no GROUP BY needed
128
+ - Column names in WHERE clauses use short names (without table alias prefix)
129
129
 
130
130
  ---
131
131
 
132
- ## 管理命令
132
+ ## Management Commands
133
133
 
134
- | 命令 | 说明 |
134
+ | Command | Description |
135
135
  |---|---|
136
- | `CREATE SEMANTIC VIEW` | 创建语义视图 |
137
- | `DROP SEMANTIC VIEW IF EXISTS <名称>` | 删除语义视图 |
138
- | `SHOW SEMANTIC VIEWS` | 列出当前 Schema 所有语义视图 |
139
- | `SHOW SEMANTIC VIEWS IN <schema>` | 列出指定 Schema 的语义视图 |
140
- | `DESC EXTENDED <名称>` | 查看详细定义(逻辑表/维度/指标/外键/索引) |
136
+ | `CREATE SEMANTIC VIEW` | Create a semantic view |
137
+ | `DROP SEMANTIC VIEW IF EXISTS <name>` | Drop a semantic view |
138
+ | `SHOW SEMANTIC VIEWS` | List all semantic views in the current schema |
139
+ | `SHOW SEMANTIC VIEWS IN <schema>` | List semantic views in a specified schema |
140
+ | `DESC EXTENDED <name>` | View detailed definition (logical tables/dimensions/metrics/foreign keys/indexes) |
141
141
 
142
142
  ---
143
143
 
144
- ## 最佳实践
144
+ ## Best Practices
145
145
 
146
146
  ```sql
147
- -- 1. 幂等创建(始终先删再建)
147
+ -- 1. Idempotent creation (always drop before create)
148
148
  DROP SEMANTIC VIEW IF EXISTS my_view;
149
149
  CREATE SEMANTIC VIEW my_view ...;
150
150
 
151
- -- 2. 使用有意义的业务术语命名
152
- -- 好:customer_name, total_revenue, order_date
153
- -- 差:c_name, sum_totalprice, o_orderdate
151
+ -- 2. Use meaningful business terminology for naming
152
+ -- Good: customer_name, total_revenue, order_date
153
+ -- Bad: c_name, sum_totalprice, o_orderdate
154
154
 
155
- -- 3. 合理设置维度元数据
156
- -- is_time=true 用于日期/时间维度
157
- -- is_unique=true 用于主键类维度(如客户ID、订单号)
158
- -- enum_values 用于状态类维度(如订单状态)
155
+ -- 3. Set dimension metadata appropriately
156
+ -- is_time=true for date/time dimensions
157
+ -- is_unique=true for primary-key-like dimensions (e.g., customer ID, order number)
158
+ -- enum_values for status-type dimensions (e.g., order status)
159
159
 
160
- -- 4. 计算维度示例
160
+ -- 4. Computed dimension examples
161
161
  DIMENSIONS (
162
- orders.order_year AS YEAR(o_orderdate) -- 从日期提取年份
163
- COMMENT = '下单年份',
164
- orders.order_month AS MONTH(o_orderdate) -- 从日期提取月份
165
- COMMENT = '下单月份'
162
+ orders.order_year AS YEAR(o_orderdate) -- Extract year from date
163
+ COMMENT = 'Order year',
164
+ orders.order_month AS MONTH(o_orderdate) -- Extract month from date
165
+ COMMENT = 'Order month'
166
166
  )
167
167
  ```