@rasmusengelbrecht/pi-semantic-query 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -8,14 +8,14 @@ It gives pi tools to discover metrics, inspect definitions, validate a model, an
8
8
 
9
9
  - pi coding agent
10
10
  - Node/npm for installing the pi package
11
- - `semantic-query-compiler` installed so the `semantic` CLI is on `PATH`
11
+ - `semantic-query-compiler >= 0.1.2` installed so the `semantic` CLI is on `PATH`
12
12
  - a semantic model in the project, usually `semantic.yml`
13
13
 
14
14
  Install the Python compiler first:
15
15
 
16
16
  ```bash
17
- uv tool install 'semantic-query-compiler @ git+https://github.com/rasmusengelbrecht/semantic-query-compiler.git'
18
- semantic --help
17
+ uv tool install 'semantic-query-compiler>=0.1.2'
18
+ semantic --version
19
19
  ```
20
20
 
21
21
  ## Install in pi
@@ -50,7 +50,13 @@ The package registers a bundled `semantic-query` skill plus these pi tools:
50
50
 
51
51
  The skill teaches pi the default workflow: search before guessing metric IDs, describe ambiguous metrics, validate model changes, prefer `period`, and never present compiled SQL as executed results.
52
52
 
53
- All tools shell out to the local `semantic` CLI. By default they look for one of:
53
+ All tools shell out to the local `semantic` CLI. If target relation flags fail with `unrecognized arguments`, upgrade the Python CLI:
54
+
55
+ ```bash
56
+ uv tool install 'semantic-query-compiler>=0.1.2' --force
57
+ ```
58
+
59
+ By default tools look for one of:
54
60
 
55
61
  - `semantic.yml`
56
62
  - `semantic.yaml`
@@ -85,6 +91,23 @@ Example request shape for `semantic_compile`:
85
91
  }
86
92
  ```
87
93
 
94
+ For target series, pass `targetTable`. Use `targetProject` and `targetSchema` when the warehouse needs a qualified target relation but you want to keep the table name generic:
95
+
96
+ ```json
97
+ {
98
+ "metricId": "revenue",
99
+ "period": "current year",
100
+ "dialect": "bigquery",
101
+ "targetProject": "warehouse-project",
102
+ "targetSchema": "analytics",
103
+ "targetTable": "metric_targets",
104
+ "request": {
105
+ "timeGrain": "monthly",
106
+ "targetSeries": "budget_current"
107
+ }
108
+ }
109
+ ```
110
+
88
111
  ## Safety boundary
89
112
 
90
113
  This package is compile-only by design. `semantic_compile` returns SQL; it does not run the SQL. Query execution touches credentials, cost, and data access, so execution should stay in the caller's existing warehouse tooling or a separate explicitly configured integration.
@@ -65,7 +65,9 @@ const CompileParams = Type.Intersect([
65
65
  Type.Literal("json"),
66
66
  Type.Literal("explain"),
67
67
  ], { description: "Output format. Defaults to sql." })),
68
- targetTable: Type.Optional(Type.String({ description: "Optional target table for targetSeries requests." })),
68
+ targetTable: Type.Optional(Type.String({ description: "Optional target table for targetSeries requests. May be fully qualified, or bare when targetProject/targetSchema are supplied." })),
69
+ targetProject: Type.Optional(Type.String({ description: "Optional target table project/catalog." })),
70
+ targetSchema: Type.Optional(Type.String({ description: "Optional target table schema/dataset." })),
69
71
  targetMetricColumn: Type.Optional(Type.String({ description: "Target metric id column. Defaults to metric_id." })),
70
72
  targetSeriesColumn: Type.Optional(Type.String({ description: "Target series column. Defaults to target_series." })),
71
73
  targetTimeColumn: Type.Optional(Type.String({ description: "Target time column. Defaults to metric_time." })),
@@ -114,6 +116,13 @@ function runSemantic(
114
116
  const result = { stdout, stderr, command: [command, ...args] };
115
117
  if (error) {
116
118
  const message = stderr.trim() || error.message;
119
+ if (message.includes("unrecognized arguments") && (message.includes("--target-project") || message.includes("--target-schema"))) {
120
+ reject(new Error(
121
+ `${command} failed because targetProject/targetSchema require semantic-query-compiler >= 0.1.1. `
122
+ + `Upgrade the Python CLI with: uv tool install semantic-query-compiler>=0.1.2 --force. Original error: ${message}`,
123
+ ));
124
+ return;
125
+ }
117
126
  reject(new Error(`${command} failed: ${message}`));
118
127
  return;
119
128
  }
@@ -249,6 +258,8 @@ export default function semanticQueryExtension(pi: ExtensionAPI) {
249
258
  if (params.dialect) args.push("--dialect", params.dialect);
250
259
  if (params.format) args.push("--format", params.format);
251
260
  if (params.targetTable) args.push("--target-table", params.targetTable);
261
+ if (params.targetProject) args.push("--target-project", params.targetProject);
262
+ if (params.targetSchema) args.push("--target-schema", params.targetSchema);
252
263
  if (params.targetMetricColumn) args.push("--target-metric-column", params.targetMetricColumn);
253
264
  if (params.targetSeriesColumn) args.push("--target-series-column", params.targetSeriesColumn);
254
265
  if (params.targetTimeColumn) args.push("--target-time-column", params.targetTimeColumn);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rasmusengelbrecht/pi-semantic-query",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Compile and inspect governed semantic metrics from pi coding agent",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -7,6 +7,8 @@ description: Compile and inspect governed semantic metrics with semantic-query-c
7
7
 
8
8
  Use the `semantic_*` tools from this package to discover governed metrics and compile inspectable SQL. These tools do **not** execute warehouse queries.
9
9
 
10
+ This package shells out to the local `semantic` CLI and expects `semantic-query-compiler >= 0.1.2`. If a tool reports `unrecognized arguments` for target relation flags, tell the user to upgrade with `uv tool install 'semantic-query-compiler>=0.1.2' --force` and verify `semantic --version`.
11
+
10
12
  ## Default workflow
11
13
 
12
14
  1. Start with `semantic_search_metrics` when the user describes a metric in business language.
@@ -32,6 +34,23 @@ Prefer period-based requests for CLI/agent workflows:
32
34
  }
33
35
  ```
34
36
 
37
+ For target series, pass `targetTable`. If the warehouse needs qualified table names, prefer generic relation parts instead of hard-coded company presets:
38
+
39
+ ```json
40
+ {
41
+ "metricId": "revenue",
42
+ "period": "current year",
43
+ "dialect": "bigquery",
44
+ "targetProject": "warehouse-project",
45
+ "targetSchema": "analytics",
46
+ "targetTable": "metric_targets",
47
+ "request": {
48
+ "timeGrain": "monthly",
49
+ "targetSeries": "budget_current"
50
+ }
51
+ }
52
+ ```
53
+
35
54
  Use raw `fromDate` / `toDate` only when the user needs exact fixed boundaries or provides a request JSON shape that already has them.
36
55
 
37
56
  ## Safety boundary