agent-semantic-layer 0.0.1__py3-none-any.whl
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.
- agent_semantic_layer/__init__.py +63 -0
- agent_semantic_layer/backends/__init__.py +1 -0
- agent_semantic_layer/backends/sqlalchemy.py +38 -0
- agent_semantic_layer/backends/sqlalchemy_compiler.py +525 -0
- agent_semantic_layer/core/__init__.py +1 -0
- agent_semantic_layer/core/backend.py +23 -0
- agent_semantic_layer/core/context.py +197 -0
- agent_semantic_layer/core/errors.py +5 -0
- agent_semantic_layer/core/loader.py +77 -0
- agent_semantic_layer/core/model.py +347 -0
- agent_semantic_layer/core/prompt.py +153 -0
- agent_semantic_layer/core/query.py +131 -0
- agent_semantic_layer/integrations/__init__.py +1 -0
- agent_semantic_layer/integrations/langchain_middleware.py +85 -0
- agent_semantic_layer/integrations/langchain_tools.py +63 -0
- agent_semantic_layer/semantic-view.schema.json +1054 -0
- agent_semantic_layer-0.0.1.dist-info/METADATA +201 -0
- agent_semantic_layer-0.0.1.dist-info/RECORD +20 -0
- agent_semantic_layer-0.0.1.dist-info/WHEEL +4 -0
- agent_semantic_layer-0.0.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,1054 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$defs": {
|
|
4
|
+
"BaseTable": {
|
|
5
|
+
"anyOf": [
|
|
6
|
+
{
|
|
7
|
+
"properties": {
|
|
8
|
+
"table": {
|
|
9
|
+
"minLength": 1,
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"definition": {
|
|
13
|
+
"type": "null"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"required": [
|
|
17
|
+
"table"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"properties": {
|
|
22
|
+
"definition": {
|
|
23
|
+
"minLength": 1,
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"database": {
|
|
27
|
+
"type": "null"
|
|
28
|
+
},
|
|
29
|
+
"schema": {
|
|
30
|
+
"type": "null"
|
|
31
|
+
},
|
|
32
|
+
"table": {
|
|
33
|
+
"type": "null"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"required": [
|
|
37
|
+
"definition"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"description": "Physical binding: a fully-qualified table OR a SQL query definition.",
|
|
42
|
+
"properties": {
|
|
43
|
+
"database": {
|
|
44
|
+
"anyOf": [
|
|
45
|
+
{
|
|
46
|
+
"minLength": 1,
|
|
47
|
+
"type": "string"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"type": "null"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"default": null,
|
|
54
|
+
"title": "Database"
|
|
55
|
+
},
|
|
56
|
+
"schema": {
|
|
57
|
+
"anyOf": [
|
|
58
|
+
{
|
|
59
|
+
"minLength": 1,
|
|
60
|
+
"type": "string"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"type": "null"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"default": null,
|
|
67
|
+
"title": "Schema"
|
|
68
|
+
},
|
|
69
|
+
"table": {
|
|
70
|
+
"anyOf": [
|
|
71
|
+
{
|
|
72
|
+
"minLength": 1,
|
|
73
|
+
"type": "string"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"type": "null"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"default": null,
|
|
80
|
+
"title": "Table"
|
|
81
|
+
},
|
|
82
|
+
"definition": {
|
|
83
|
+
"anyOf": [
|
|
84
|
+
{
|
|
85
|
+
"minLength": 1,
|
|
86
|
+
"type": "string"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"type": "null"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"default": null,
|
|
93
|
+
"description": "A SQL query used instead of database/schema/table.",
|
|
94
|
+
"title": "Definition"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"title": "BaseTable",
|
|
98
|
+
"type": "object"
|
|
99
|
+
},
|
|
100
|
+
"DerivedMetric": {
|
|
101
|
+
"description": "A view-level metric whose expr may reference items across tables.",
|
|
102
|
+
"properties": {
|
|
103
|
+
"name": {
|
|
104
|
+
"title": "Name",
|
|
105
|
+
"type": "string"
|
|
106
|
+
},
|
|
107
|
+
"expr": {
|
|
108
|
+
"title": "Expr",
|
|
109
|
+
"type": "string"
|
|
110
|
+
},
|
|
111
|
+
"description": {
|
|
112
|
+
"anyOf": [
|
|
113
|
+
{
|
|
114
|
+
"type": "string"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"type": "null"
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"default": null,
|
|
121
|
+
"title": "Description"
|
|
122
|
+
},
|
|
123
|
+
"synonyms": {
|
|
124
|
+
"items": {
|
|
125
|
+
"type": "string"
|
|
126
|
+
},
|
|
127
|
+
"title": "Synonyms",
|
|
128
|
+
"type": "array"
|
|
129
|
+
},
|
|
130
|
+
"data_type": {
|
|
131
|
+
"anyOf": [
|
|
132
|
+
{
|
|
133
|
+
"enum": [
|
|
134
|
+
"string",
|
|
135
|
+
"number",
|
|
136
|
+
"integer",
|
|
137
|
+
"date",
|
|
138
|
+
"timestamp",
|
|
139
|
+
"boolean"
|
|
140
|
+
],
|
|
141
|
+
"type": "string"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"type": "null"
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
"default": null,
|
|
148
|
+
"title": "Data Type"
|
|
149
|
+
},
|
|
150
|
+
"access_modifier": {
|
|
151
|
+
"default": "public_access",
|
|
152
|
+
"enum": [
|
|
153
|
+
"public_access",
|
|
154
|
+
"private_access"
|
|
155
|
+
],
|
|
156
|
+
"title": "Access Modifier",
|
|
157
|
+
"type": "string"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"required": [
|
|
161
|
+
"name",
|
|
162
|
+
"expr"
|
|
163
|
+
],
|
|
164
|
+
"title": "DerivedMetric",
|
|
165
|
+
"type": "object"
|
|
166
|
+
},
|
|
167
|
+
"Dimension": {
|
|
168
|
+
"description": "Categorical / descriptive attribute (row-level, non-aggregate).",
|
|
169
|
+
"properties": {
|
|
170
|
+
"name": {
|
|
171
|
+
"title": "Name",
|
|
172
|
+
"type": "string"
|
|
173
|
+
},
|
|
174
|
+
"expr": {
|
|
175
|
+
"description": "Physical, row-level SQL expression.",
|
|
176
|
+
"title": "Expr",
|
|
177
|
+
"type": "string"
|
|
178
|
+
},
|
|
179
|
+
"description": {
|
|
180
|
+
"anyOf": [
|
|
181
|
+
{
|
|
182
|
+
"type": "string"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"type": "null"
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
"default": null,
|
|
189
|
+
"title": "Description"
|
|
190
|
+
},
|
|
191
|
+
"synonyms": {
|
|
192
|
+
"items": {
|
|
193
|
+
"type": "string"
|
|
194
|
+
},
|
|
195
|
+
"title": "Synonyms",
|
|
196
|
+
"type": "array"
|
|
197
|
+
},
|
|
198
|
+
"data_type": {
|
|
199
|
+
"anyOf": [
|
|
200
|
+
{
|
|
201
|
+
"enum": [
|
|
202
|
+
"string",
|
|
203
|
+
"number",
|
|
204
|
+
"integer",
|
|
205
|
+
"date",
|
|
206
|
+
"timestamp",
|
|
207
|
+
"boolean"
|
|
208
|
+
],
|
|
209
|
+
"type": "string"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"type": "null"
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
"default": null,
|
|
216
|
+
"title": "Data Type"
|
|
217
|
+
},
|
|
218
|
+
"is_enum": {
|
|
219
|
+
"default": false,
|
|
220
|
+
"title": "Is Enum",
|
|
221
|
+
"type": "boolean"
|
|
222
|
+
},
|
|
223
|
+
"labels": {
|
|
224
|
+
"items": {
|
|
225
|
+
"type": "string"
|
|
226
|
+
},
|
|
227
|
+
"title": "Labels",
|
|
228
|
+
"type": "array"
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
"required": [
|
|
232
|
+
"name",
|
|
233
|
+
"expr"
|
|
234
|
+
],
|
|
235
|
+
"title": "Dimension",
|
|
236
|
+
"type": "object"
|
|
237
|
+
},
|
|
238
|
+
"Fact": {
|
|
239
|
+
"description": "Raw row-level numeric attribute; a building block for metrics.",
|
|
240
|
+
"properties": {
|
|
241
|
+
"name": {
|
|
242
|
+
"title": "Name",
|
|
243
|
+
"type": "string"
|
|
244
|
+
},
|
|
245
|
+
"expr": {
|
|
246
|
+
"description": "Physical, row-level SQL expression.",
|
|
247
|
+
"title": "Expr",
|
|
248
|
+
"type": "string"
|
|
249
|
+
},
|
|
250
|
+
"description": {
|
|
251
|
+
"anyOf": [
|
|
252
|
+
{
|
|
253
|
+
"type": "string"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"type": "null"
|
|
257
|
+
}
|
|
258
|
+
],
|
|
259
|
+
"default": null,
|
|
260
|
+
"title": "Description"
|
|
261
|
+
},
|
|
262
|
+
"synonyms": {
|
|
263
|
+
"items": {
|
|
264
|
+
"type": "string"
|
|
265
|
+
},
|
|
266
|
+
"title": "Synonyms",
|
|
267
|
+
"type": "array"
|
|
268
|
+
},
|
|
269
|
+
"data_type": {
|
|
270
|
+
"anyOf": [
|
|
271
|
+
{
|
|
272
|
+
"enum": [
|
|
273
|
+
"string",
|
|
274
|
+
"number",
|
|
275
|
+
"integer",
|
|
276
|
+
"date",
|
|
277
|
+
"timestamp",
|
|
278
|
+
"boolean"
|
|
279
|
+
],
|
|
280
|
+
"type": "string"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"type": "null"
|
|
284
|
+
}
|
|
285
|
+
],
|
|
286
|
+
"default": null,
|
|
287
|
+
"title": "Data Type"
|
|
288
|
+
},
|
|
289
|
+
"access_modifier": {
|
|
290
|
+
"default": "public_access",
|
|
291
|
+
"enum": [
|
|
292
|
+
"public_access",
|
|
293
|
+
"private_access"
|
|
294
|
+
],
|
|
295
|
+
"title": "Access Modifier",
|
|
296
|
+
"type": "string"
|
|
297
|
+
},
|
|
298
|
+
"labels": {
|
|
299
|
+
"items": {
|
|
300
|
+
"type": "string"
|
|
301
|
+
},
|
|
302
|
+
"title": "Labels",
|
|
303
|
+
"type": "array"
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
"required": [
|
|
307
|
+
"name",
|
|
308
|
+
"expr"
|
|
309
|
+
],
|
|
310
|
+
"title": "Fact",
|
|
311
|
+
"type": "object"
|
|
312
|
+
},
|
|
313
|
+
"FilterCondition": {
|
|
314
|
+
"description": "A leaf predicate: ``field <operator> value``.\n\n``value`` is a scalar for comparison ops, an array for ``in`` / ``not_in`` /\n``between`` (``[low, high]``), and omitted for ``is_null`` / ``is_not_null``.",
|
|
315
|
+
"properties": {
|
|
316
|
+
"field": {
|
|
317
|
+
"description": "Logical item name the predicate applies to.",
|
|
318
|
+
"title": "Field",
|
|
319
|
+
"type": "string"
|
|
320
|
+
},
|
|
321
|
+
"operator": {
|
|
322
|
+
"enum": [
|
|
323
|
+
"eq",
|
|
324
|
+
"ne",
|
|
325
|
+
"gt",
|
|
326
|
+
"gte",
|
|
327
|
+
"lt",
|
|
328
|
+
"lte",
|
|
329
|
+
"in",
|
|
330
|
+
"not_in",
|
|
331
|
+
"between",
|
|
332
|
+
"like",
|
|
333
|
+
"not_like",
|
|
334
|
+
"is_null",
|
|
335
|
+
"is_not_null"
|
|
336
|
+
],
|
|
337
|
+
"title": "Operator",
|
|
338
|
+
"type": "string"
|
|
339
|
+
},
|
|
340
|
+
"value": {
|
|
341
|
+
"anyOf": [
|
|
342
|
+
{
|
|
343
|
+
"type": "string"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"type": "integer"
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"type": "number"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"type": "boolean"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
"items": {
|
|
356
|
+
"anyOf": [
|
|
357
|
+
{
|
|
358
|
+
"type": "string"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"type": "integer"
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
"type": "number"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"type": "boolean"
|
|
368
|
+
}
|
|
369
|
+
]
|
|
370
|
+
},
|
|
371
|
+
"type": "array"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"type": "null"
|
|
375
|
+
}
|
|
376
|
+
],
|
|
377
|
+
"default": null,
|
|
378
|
+
"description": "Scalar for comparisons; array for in/not_in/between; omit for null tests.",
|
|
379
|
+
"title": "Value"
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
"required": [
|
|
383
|
+
"field",
|
|
384
|
+
"operator"
|
|
385
|
+
],
|
|
386
|
+
"title": "FilterCondition",
|
|
387
|
+
"type": "object"
|
|
388
|
+
},
|
|
389
|
+
"FilterGroup": {
|
|
390
|
+
"description": "A boolean group combining nested conditions/groups with and/or.",
|
|
391
|
+
"properties": {
|
|
392
|
+
"op": {
|
|
393
|
+
"enum": [
|
|
394
|
+
"and",
|
|
395
|
+
"or"
|
|
396
|
+
],
|
|
397
|
+
"title": "Op",
|
|
398
|
+
"type": "string"
|
|
399
|
+
},
|
|
400
|
+
"conditions": {
|
|
401
|
+
"items": {
|
|
402
|
+
"anyOf": [
|
|
403
|
+
{
|
|
404
|
+
"$ref": "#/$defs/FilterGroup"
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"$ref": "#/$defs/FilterCondition"
|
|
408
|
+
}
|
|
409
|
+
]
|
|
410
|
+
},
|
|
411
|
+
"minItems": 1,
|
|
412
|
+
"title": "Conditions",
|
|
413
|
+
"type": "array"
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
"required": [
|
|
417
|
+
"op",
|
|
418
|
+
"conditions"
|
|
419
|
+
],
|
|
420
|
+
"title": "FilterGroup",
|
|
421
|
+
"type": "object"
|
|
422
|
+
},
|
|
423
|
+
"KeySpec": {
|
|
424
|
+
"properties": {
|
|
425
|
+
"columns": {
|
|
426
|
+
"items": {
|
|
427
|
+
"type": "string"
|
|
428
|
+
},
|
|
429
|
+
"minItems": 1,
|
|
430
|
+
"title": "Columns",
|
|
431
|
+
"type": "array"
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
"required": [
|
|
435
|
+
"columns"
|
|
436
|
+
],
|
|
437
|
+
"title": "KeySpec",
|
|
438
|
+
"type": "object"
|
|
439
|
+
},
|
|
440
|
+
"LogicalTable": {
|
|
441
|
+
"description": "A business entity backed by a physical table/view.",
|
|
442
|
+
"properties": {
|
|
443
|
+
"name": {
|
|
444
|
+
"title": "Name",
|
|
445
|
+
"type": "string"
|
|
446
|
+
},
|
|
447
|
+
"base_table": {
|
|
448
|
+
"$ref": "#/$defs/BaseTable"
|
|
449
|
+
},
|
|
450
|
+
"description": {
|
|
451
|
+
"anyOf": [
|
|
452
|
+
{
|
|
453
|
+
"type": "string"
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
"type": "null"
|
|
457
|
+
}
|
|
458
|
+
],
|
|
459
|
+
"default": null,
|
|
460
|
+
"title": "Description"
|
|
461
|
+
},
|
|
462
|
+
"primary_key": {
|
|
463
|
+
"anyOf": [
|
|
464
|
+
{
|
|
465
|
+
"$ref": "#/$defs/KeySpec"
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
"type": "null"
|
|
469
|
+
}
|
|
470
|
+
],
|
|
471
|
+
"default": null
|
|
472
|
+
},
|
|
473
|
+
"unique_keys": {
|
|
474
|
+
"items": {
|
|
475
|
+
"$ref": "#/$defs/KeySpec"
|
|
476
|
+
},
|
|
477
|
+
"title": "Unique Keys",
|
|
478
|
+
"type": "array"
|
|
479
|
+
},
|
|
480
|
+
"dimensions": {
|
|
481
|
+
"items": {
|
|
482
|
+
"$ref": "#/$defs/Dimension"
|
|
483
|
+
},
|
|
484
|
+
"title": "Dimensions",
|
|
485
|
+
"type": "array"
|
|
486
|
+
},
|
|
487
|
+
"time_dimensions": {
|
|
488
|
+
"items": {
|
|
489
|
+
"$ref": "#/$defs/Dimension"
|
|
490
|
+
},
|
|
491
|
+
"title": "Time Dimensions",
|
|
492
|
+
"type": "array"
|
|
493
|
+
},
|
|
494
|
+
"facts": {
|
|
495
|
+
"items": {
|
|
496
|
+
"$ref": "#/$defs/Fact"
|
|
497
|
+
},
|
|
498
|
+
"title": "Facts",
|
|
499
|
+
"type": "array"
|
|
500
|
+
},
|
|
501
|
+
"metrics": {
|
|
502
|
+
"items": {
|
|
503
|
+
"$ref": "#/$defs/Metric"
|
|
504
|
+
},
|
|
505
|
+
"title": "Metrics",
|
|
506
|
+
"type": "array"
|
|
507
|
+
},
|
|
508
|
+
"filters": {
|
|
509
|
+
"items": {
|
|
510
|
+
"$ref": "#/$defs/NamedFilter"
|
|
511
|
+
},
|
|
512
|
+
"title": "Filters",
|
|
513
|
+
"type": "array"
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
"required": [
|
|
517
|
+
"name",
|
|
518
|
+
"base_table"
|
|
519
|
+
],
|
|
520
|
+
"title": "LogicalTable",
|
|
521
|
+
"type": "object"
|
|
522
|
+
},
|
|
523
|
+
"Metric": {
|
|
524
|
+
"description": "Aggregation / KPI scoped to a single logical table.",
|
|
525
|
+
"properties": {
|
|
526
|
+
"name": {
|
|
527
|
+
"title": "Name",
|
|
528
|
+
"type": "string"
|
|
529
|
+
},
|
|
530
|
+
"expr": {
|
|
531
|
+
"description": "Physical SQL expression that aggregates.",
|
|
532
|
+
"title": "Expr",
|
|
533
|
+
"type": "string"
|
|
534
|
+
},
|
|
535
|
+
"description": {
|
|
536
|
+
"anyOf": [
|
|
537
|
+
{
|
|
538
|
+
"type": "string"
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
"type": "null"
|
|
542
|
+
}
|
|
543
|
+
],
|
|
544
|
+
"default": null,
|
|
545
|
+
"title": "Description"
|
|
546
|
+
},
|
|
547
|
+
"synonyms": {
|
|
548
|
+
"items": {
|
|
549
|
+
"type": "string"
|
|
550
|
+
},
|
|
551
|
+
"title": "Synonyms",
|
|
552
|
+
"type": "array"
|
|
553
|
+
},
|
|
554
|
+
"data_type": {
|
|
555
|
+
"anyOf": [
|
|
556
|
+
{
|
|
557
|
+
"enum": [
|
|
558
|
+
"string",
|
|
559
|
+
"number",
|
|
560
|
+
"integer",
|
|
561
|
+
"date",
|
|
562
|
+
"timestamp",
|
|
563
|
+
"boolean"
|
|
564
|
+
],
|
|
565
|
+
"type": "string"
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
"type": "null"
|
|
569
|
+
}
|
|
570
|
+
],
|
|
571
|
+
"default": null,
|
|
572
|
+
"title": "Data Type"
|
|
573
|
+
},
|
|
574
|
+
"access_modifier": {
|
|
575
|
+
"default": "public_access",
|
|
576
|
+
"enum": [
|
|
577
|
+
"public_access",
|
|
578
|
+
"private_access"
|
|
579
|
+
],
|
|
580
|
+
"title": "Access Modifier",
|
|
581
|
+
"type": "string"
|
|
582
|
+
},
|
|
583
|
+
"using_relationships": {
|
|
584
|
+
"items": {
|
|
585
|
+
"type": "string"
|
|
586
|
+
},
|
|
587
|
+
"title": "Using Relationships",
|
|
588
|
+
"type": "array"
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
"required": [
|
|
592
|
+
"name",
|
|
593
|
+
"expr"
|
|
594
|
+
],
|
|
595
|
+
"title": "Metric",
|
|
596
|
+
"type": "object"
|
|
597
|
+
},
|
|
598
|
+
"NamedFilter": {
|
|
599
|
+
"description": "A reusable, row-level boolean predicate fragment.",
|
|
600
|
+
"properties": {
|
|
601
|
+
"name": {
|
|
602
|
+
"title": "Name",
|
|
603
|
+
"type": "string"
|
|
604
|
+
},
|
|
605
|
+
"expr": {
|
|
606
|
+
"title": "Expr",
|
|
607
|
+
"type": "string"
|
|
608
|
+
},
|
|
609
|
+
"description": {
|
|
610
|
+
"anyOf": [
|
|
611
|
+
{
|
|
612
|
+
"type": "string"
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
"type": "null"
|
|
616
|
+
}
|
|
617
|
+
],
|
|
618
|
+
"default": null,
|
|
619
|
+
"title": "Description"
|
|
620
|
+
},
|
|
621
|
+
"synonyms": {
|
|
622
|
+
"items": {
|
|
623
|
+
"type": "string"
|
|
624
|
+
},
|
|
625
|
+
"title": "Synonyms",
|
|
626
|
+
"type": "array"
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
"required": [
|
|
630
|
+
"name",
|
|
631
|
+
"expr"
|
|
632
|
+
],
|
|
633
|
+
"title": "NamedFilter",
|
|
634
|
+
"type": "object"
|
|
635
|
+
},
|
|
636
|
+
"OrderBy": {
|
|
637
|
+
"properties": {
|
|
638
|
+
"field": {
|
|
639
|
+
"description": "A selected item name or a declared alias to sort by.",
|
|
640
|
+
"title": "Field",
|
|
641
|
+
"type": "string"
|
|
642
|
+
},
|
|
643
|
+
"direction": {
|
|
644
|
+
"default": "asc",
|
|
645
|
+
"enum": [
|
|
646
|
+
"asc",
|
|
647
|
+
"desc"
|
|
648
|
+
],
|
|
649
|
+
"title": "Direction",
|
|
650
|
+
"type": "string"
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
"required": [
|
|
654
|
+
"field"
|
|
655
|
+
],
|
|
656
|
+
"title": "OrderBy",
|
|
657
|
+
"type": "object"
|
|
658
|
+
},
|
|
659
|
+
"Relationship": {
|
|
660
|
+
"description": "A declared join between two logical tables.",
|
|
661
|
+
"properties": {
|
|
662
|
+
"name": {
|
|
663
|
+
"title": "Name",
|
|
664
|
+
"type": "string"
|
|
665
|
+
},
|
|
666
|
+
"left_table": {
|
|
667
|
+
"title": "Left Table",
|
|
668
|
+
"type": "string"
|
|
669
|
+
},
|
|
670
|
+
"right_table": {
|
|
671
|
+
"title": "Right Table",
|
|
672
|
+
"type": "string"
|
|
673
|
+
},
|
|
674
|
+
"relationship_columns": {
|
|
675
|
+
"items": {
|
|
676
|
+
"$ref": "#/$defs/RelationshipColumn"
|
|
677
|
+
},
|
|
678
|
+
"minItems": 1,
|
|
679
|
+
"title": "Relationship Columns",
|
|
680
|
+
"type": "array"
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
"required": [
|
|
684
|
+
"name",
|
|
685
|
+
"left_table",
|
|
686
|
+
"right_table",
|
|
687
|
+
"relationship_columns"
|
|
688
|
+
],
|
|
689
|
+
"title": "Relationship",
|
|
690
|
+
"type": "object"
|
|
691
|
+
},
|
|
692
|
+
"RelationshipColumn": {
|
|
693
|
+
"properties": {
|
|
694
|
+
"left_column": {
|
|
695
|
+
"title": "Left Column",
|
|
696
|
+
"type": "string"
|
|
697
|
+
},
|
|
698
|
+
"right_column": {
|
|
699
|
+
"title": "Right Column",
|
|
700
|
+
"type": "string"
|
|
701
|
+
},
|
|
702
|
+
"type": {
|
|
703
|
+
"anyOf": [
|
|
704
|
+
{
|
|
705
|
+
"enum": [
|
|
706
|
+
"asof",
|
|
707
|
+
"range"
|
|
708
|
+
],
|
|
709
|
+
"type": "string"
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"type": "null"
|
|
713
|
+
}
|
|
714
|
+
],
|
|
715
|
+
"default": null,
|
|
716
|
+
"title": "Type"
|
|
717
|
+
},
|
|
718
|
+
"right_range": {
|
|
719
|
+
"anyOf": [
|
|
720
|
+
{
|
|
721
|
+
"additionalProperties": true,
|
|
722
|
+
"type": "object"
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
"type": "null"
|
|
726
|
+
}
|
|
727
|
+
],
|
|
728
|
+
"default": null,
|
|
729
|
+
"title": "Right Range"
|
|
730
|
+
}
|
|
731
|
+
},
|
|
732
|
+
"required": [
|
|
733
|
+
"left_column",
|
|
734
|
+
"right_column"
|
|
735
|
+
],
|
|
736
|
+
"title": "RelationshipColumn",
|
|
737
|
+
"type": "object"
|
|
738
|
+
},
|
|
739
|
+
"SelectionItem": {
|
|
740
|
+
"description": "A metric / dimension / fact to select.\n\n``name`` must be a logical name declared in the model, qualified as\n``table.item`` or unqualified when globally unique. ``alias`` optionally\nnames the output column and can be referenced from ``order_by``.",
|
|
741
|
+
"properties": {
|
|
742
|
+
"name": {
|
|
743
|
+
"description": "Logical item name, e.g. 'customer.customer_tier' or 'total_forecast_qty'.",
|
|
744
|
+
"title": "Name",
|
|
745
|
+
"type": "string"
|
|
746
|
+
},
|
|
747
|
+
"alias": {
|
|
748
|
+
"anyOf": [
|
|
749
|
+
{
|
|
750
|
+
"type": "string"
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
"type": "null"
|
|
754
|
+
}
|
|
755
|
+
],
|
|
756
|
+
"default": null,
|
|
757
|
+
"description": "Optional output column name; usable in order_by.",
|
|
758
|
+
"title": "Alias"
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
"required": [
|
|
762
|
+
"name"
|
|
763
|
+
],
|
|
764
|
+
"title": "SelectionItem",
|
|
765
|
+
"type": "object"
|
|
766
|
+
},
|
|
767
|
+
"SemanticQuery": {
|
|
768
|
+
"description": "A request expressed only in business terms declared by the model.\n\nA valid query selects at least one of ``metrics`` / ``dimensions`` /\n``facts``. Selecting one or more metrics puts the query in *aggregated* mode\n(grouped by the selected dimensions); otherwise it is a *detail* projection.",
|
|
769
|
+
"properties": {
|
|
770
|
+
"model": {
|
|
771
|
+
"description": "Which semantic model to query.",
|
|
772
|
+
"title": "Model",
|
|
773
|
+
"type": "string"
|
|
774
|
+
},
|
|
775
|
+
"metrics": {
|
|
776
|
+
"description": "Metrics to compute (aggregated mode).",
|
|
777
|
+
"items": {
|
|
778
|
+
"$ref": "#/$defs/SelectionItem"
|
|
779
|
+
},
|
|
780
|
+
"title": "Metrics",
|
|
781
|
+
"type": "array"
|
|
782
|
+
},
|
|
783
|
+
"dimensions": {
|
|
784
|
+
"description": "Attributes to group by / return.",
|
|
785
|
+
"items": {
|
|
786
|
+
"$ref": "#/$defs/SelectionItem"
|
|
787
|
+
},
|
|
788
|
+
"title": "Dimensions",
|
|
789
|
+
"type": "array"
|
|
790
|
+
},
|
|
791
|
+
"facts": {
|
|
792
|
+
"description": "Row-level values returned without grouping (detail mode).",
|
|
793
|
+
"items": {
|
|
794
|
+
"$ref": "#/$defs/SelectionItem"
|
|
795
|
+
},
|
|
796
|
+
"title": "Facts",
|
|
797
|
+
"type": "array"
|
|
798
|
+
},
|
|
799
|
+
"filters": {
|
|
800
|
+
"anyOf": [
|
|
801
|
+
{
|
|
802
|
+
"$ref": "#/$defs/FilterGroup"
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
"$ref": "#/$defs/FilterCondition"
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
"type": "null"
|
|
809
|
+
}
|
|
810
|
+
],
|
|
811
|
+
"default": null,
|
|
812
|
+
"description": "Row-level predicate (WHERE), before aggregation.",
|
|
813
|
+
"title": "Filters"
|
|
814
|
+
},
|
|
815
|
+
"having": {
|
|
816
|
+
"anyOf": [
|
|
817
|
+
{
|
|
818
|
+
"$ref": "#/$defs/FilterGroup"
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
"$ref": "#/$defs/FilterCondition"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
"type": "null"
|
|
825
|
+
}
|
|
826
|
+
],
|
|
827
|
+
"default": null,
|
|
828
|
+
"description": "Predicate on metrics (HAVING), after aggregation.",
|
|
829
|
+
"title": "Having"
|
|
830
|
+
},
|
|
831
|
+
"order_by": {
|
|
832
|
+
"items": {
|
|
833
|
+
"$ref": "#/$defs/OrderBy"
|
|
834
|
+
},
|
|
835
|
+
"title": "Order By",
|
|
836
|
+
"type": "array"
|
|
837
|
+
},
|
|
838
|
+
"limit": {
|
|
839
|
+
"anyOf": [
|
|
840
|
+
{
|
|
841
|
+
"minimum": 0,
|
|
842
|
+
"type": "integer"
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
"type": "null"
|
|
846
|
+
}
|
|
847
|
+
],
|
|
848
|
+
"default": null,
|
|
849
|
+
"title": "Limit"
|
|
850
|
+
},
|
|
851
|
+
"offset": {
|
|
852
|
+
"anyOf": [
|
|
853
|
+
{
|
|
854
|
+
"minimum": 0,
|
|
855
|
+
"type": "integer"
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
"type": "null"
|
|
859
|
+
}
|
|
860
|
+
],
|
|
861
|
+
"default": null,
|
|
862
|
+
"title": "Offset"
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
"required": [
|
|
866
|
+
"model"
|
|
867
|
+
],
|
|
868
|
+
"title": "SemanticQuery",
|
|
869
|
+
"type": "object"
|
|
870
|
+
},
|
|
871
|
+
"Variable": {
|
|
872
|
+
"properties": {
|
|
873
|
+
"name": {
|
|
874
|
+
"title": "Name",
|
|
875
|
+
"type": "string"
|
|
876
|
+
},
|
|
877
|
+
"data_type": {
|
|
878
|
+
"enum": [
|
|
879
|
+
"string",
|
|
880
|
+
"number",
|
|
881
|
+
"integer",
|
|
882
|
+
"date",
|
|
883
|
+
"timestamp",
|
|
884
|
+
"boolean"
|
|
885
|
+
],
|
|
886
|
+
"title": "Data Type",
|
|
887
|
+
"type": "string"
|
|
888
|
+
},
|
|
889
|
+
"default_value": {
|
|
890
|
+
"anyOf": [
|
|
891
|
+
{
|
|
892
|
+
"type": "string"
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
"type": "null"
|
|
896
|
+
}
|
|
897
|
+
],
|
|
898
|
+
"default": null,
|
|
899
|
+
"title": "Default Value"
|
|
900
|
+
},
|
|
901
|
+
"description": {
|
|
902
|
+
"anyOf": [
|
|
903
|
+
{
|
|
904
|
+
"type": "string"
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
"type": "null"
|
|
908
|
+
}
|
|
909
|
+
],
|
|
910
|
+
"default": null,
|
|
911
|
+
"title": "Description"
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
"required": [
|
|
915
|
+
"name",
|
|
916
|
+
"data_type"
|
|
917
|
+
],
|
|
918
|
+
"title": "Variable",
|
|
919
|
+
"type": "object"
|
|
920
|
+
},
|
|
921
|
+
"VerifiedQuery": {
|
|
922
|
+
"description": "A question -> verified example, used as an onboarding hint for the LLM.\n\nOnly the ``question`` is exposed to the LLM (as a \"you can ask me things\nlike this\" hint). The embedded ``semantic_query`` is intentionally *not*\nsurfaced: the query tool already advertises the ``SemanticQuery`` shape via\nits input schema, so re-teaching it here would be redundant.",
|
|
923
|
+
"properties": {
|
|
924
|
+
"name": {
|
|
925
|
+
"title": "Name",
|
|
926
|
+
"type": "string"
|
|
927
|
+
},
|
|
928
|
+
"question": {
|
|
929
|
+
"title": "Question",
|
|
930
|
+
"type": "string"
|
|
931
|
+
},
|
|
932
|
+
"use_as_onboarding_question": {
|
|
933
|
+
"default": false,
|
|
934
|
+
"title": "Use As Onboarding Question",
|
|
935
|
+
"type": "boolean"
|
|
936
|
+
},
|
|
937
|
+
"semantic_query": {
|
|
938
|
+
"anyOf": [
|
|
939
|
+
{
|
|
940
|
+
"$ref": "#/$defs/SemanticQuery"
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
"type": "null"
|
|
944
|
+
}
|
|
945
|
+
],
|
|
946
|
+
"default": null
|
|
947
|
+
},
|
|
948
|
+
"verified_at": {
|
|
949
|
+
"anyOf": [
|
|
950
|
+
{
|
|
951
|
+
"type": "integer"
|
|
952
|
+
},
|
|
953
|
+
{
|
|
954
|
+
"type": "null"
|
|
955
|
+
}
|
|
956
|
+
],
|
|
957
|
+
"default": null,
|
|
958
|
+
"title": "Verified At"
|
|
959
|
+
},
|
|
960
|
+
"verified_by": {
|
|
961
|
+
"anyOf": [
|
|
962
|
+
{
|
|
963
|
+
"type": "string"
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
"type": "null"
|
|
967
|
+
}
|
|
968
|
+
],
|
|
969
|
+
"default": null,
|
|
970
|
+
"title": "Verified By"
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
"required": [
|
|
974
|
+
"name",
|
|
975
|
+
"question"
|
|
976
|
+
],
|
|
977
|
+
"title": "VerifiedQuery",
|
|
978
|
+
"type": "object"
|
|
979
|
+
}
|
|
980
|
+
},
|
|
981
|
+
"description": "The in-memory semantic view loaded from a user's YAML.\n\nThis is the full domain model (both the compile-facing physical info —\n``expr`` / ``base_table`` / relationships — and the LLM-facing context —\ndescriptions / synonyms / enum values). The compiler consumes the whole\nview; the LLM only ever sees the projected :class:`SemanticContext`\n(see :meth:`context`), which strips ``expr`` and ``private_access`` items.",
|
|
982
|
+
"properties": {
|
|
983
|
+
"name": {
|
|
984
|
+
"title": "Name",
|
|
985
|
+
"type": "string"
|
|
986
|
+
},
|
|
987
|
+
"tables": {
|
|
988
|
+
"items": {
|
|
989
|
+
"$ref": "#/$defs/LogicalTable"
|
|
990
|
+
},
|
|
991
|
+
"minItems": 1,
|
|
992
|
+
"title": "Tables",
|
|
993
|
+
"type": "array"
|
|
994
|
+
},
|
|
995
|
+
"description": {
|
|
996
|
+
"anyOf": [
|
|
997
|
+
{
|
|
998
|
+
"type": "string"
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
"type": "null"
|
|
1002
|
+
}
|
|
1003
|
+
],
|
|
1004
|
+
"default": null,
|
|
1005
|
+
"title": "Description"
|
|
1006
|
+
},
|
|
1007
|
+
"relationships": {
|
|
1008
|
+
"items": {
|
|
1009
|
+
"$ref": "#/$defs/Relationship"
|
|
1010
|
+
},
|
|
1011
|
+
"title": "Relationships",
|
|
1012
|
+
"type": "array"
|
|
1013
|
+
},
|
|
1014
|
+
"variables": {
|
|
1015
|
+
"items": {
|
|
1016
|
+
"$ref": "#/$defs/Variable"
|
|
1017
|
+
},
|
|
1018
|
+
"title": "Variables",
|
|
1019
|
+
"type": "array"
|
|
1020
|
+
},
|
|
1021
|
+
"metrics": {
|
|
1022
|
+
"items": {
|
|
1023
|
+
"$ref": "#/$defs/DerivedMetric"
|
|
1024
|
+
},
|
|
1025
|
+
"title": "Metrics",
|
|
1026
|
+
"type": "array"
|
|
1027
|
+
},
|
|
1028
|
+
"verified_queries": {
|
|
1029
|
+
"items": {
|
|
1030
|
+
"$ref": "#/$defs/VerifiedQuery"
|
|
1031
|
+
},
|
|
1032
|
+
"title": "Verified Queries",
|
|
1033
|
+
"type": "array"
|
|
1034
|
+
},
|
|
1035
|
+
"custom_instructions": {
|
|
1036
|
+
"anyOf": [
|
|
1037
|
+
{
|
|
1038
|
+
"type": "string"
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
"type": "null"
|
|
1042
|
+
}
|
|
1043
|
+
],
|
|
1044
|
+
"default": null,
|
|
1045
|
+
"title": "Custom Instructions"
|
|
1046
|
+
}
|
|
1047
|
+
},
|
|
1048
|
+
"required": [
|
|
1049
|
+
"name",
|
|
1050
|
+
"tables"
|
|
1051
|
+
],
|
|
1052
|
+
"title": "SemanticView",
|
|
1053
|
+
"type": "object"
|
|
1054
|
+
}
|