Skip to content

Commit 6adb1e0

Browse files
authored
Add Graphene .gsql semantic model importer (#181)
* Add Graphene .gsql semantic model importer * Load Graphene projects in one pass * Normalize Graphene percentile metrics * Preserve explicit Graphene primary keys * Preserve one-to-many join keys * Preserve unresolved Graphene joins * Preserve composite Graphene keys * Project relationship join keys * Preserve Graphene parameterized types * Preserve unsupported Graphene join predicates * Use Graphene view output aliases * Inline Graphene computed dimensions * Choose Graphene view primary keys from projections
1 parent 9f55611 commit 6adb1e0

14 files changed

Lines changed: 2524 additions & 23 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ See `examples/` for more.
224224

225225
- SQL query interface with automatic rewriting
226226
- Automatic joins across models
227-
- Multi-format adapters (Cube, MetricFlow, LookML, Hex, Rill, Superset, Omni, BSL, GoodData LDM, OSI, AtScale SML, ThoughtSpot TML)
227+
- Multi-format adapters (Cube, MetricFlow, LookML, Hex, Rill, Superset, Omni, BSL, GoodData LDM, OSI, AtScale SML, ThoughtSpot TML, Graphene GSQL)
228228
- SQLGlot-based SQL generation and transpilation
229229
- Pydantic validation and type safety
230230
- Pre-aggregations with automatic routing
@@ -236,7 +236,7 @@ See `examples/` for more.
236236

237237
## Multi-Format Support
238238

239-
Auto-detects: Sidemantic (SQL/YAML), Cube, MetricFlow (dbt), LookML, Hex, Rill, Superset, Omni, BSL, GoodData LDM, OSI, AtScale SML, ThoughtSpot TML
239+
Auto-detects: Sidemantic (SQL/YAML), Cube, MetricFlow (dbt), LookML, Hex, Rill, Superset, Omni, BSL, GoodData LDM, OSI, AtScale SML, ThoughtSpot TML, Graphene GSQL
240240

241241
```bash
242242
sidemantic query "SELECT revenue FROM orders" --models ./my_models

docs/compatibility/graphene.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Graphene GSQL Compatibility
2+
3+
Sidemantic can import Graphene `.gsql` semantic model files through `load_from_directory()` and CLI commands that use the normal model loader.
4+
5+
The importer is a Sidemantic-owned compatibility parser for Graphene's documented model declarations. It does not bundle Graphene, call the Graphene runtime, or vendor Graphene's parser/grammar/analyzer.
6+
7+
## Supported
8+
9+
- `table name (...)` physical table definitions
10+
- `table name as (...)` derived table definitions, with the view query preserved as model SQL
11+
- `extend name (...)` blocks
12+
- Base columns as Sidemantic dimensions
13+
- Computed scalar expressions as dimensions
14+
- Aggregate expressions and measure-composed expressions as metrics
15+
- `join one` as `many_to_one`
16+
- `join many` as `one_to_many`
17+
- Graphene metadata annotations such as `#ratio`, `#pct`, `#currency=USD`, `#unit=minutes`, `#timeGrain=day`, `#timeOrdinal=month_of_year`, `#description=...`, and `#pii`
18+
19+
## Not Supported
20+
21+
- Graphene Markdown pages are not imported as semantic models.
22+
- Full GSQL query compilation is not reimplemented; `select` statements are not imported as standalone semantic models, and `table name as (...)` query text is preserved.
23+
- Graphene-specific query-time behavior such as implicit modeled joins, multi-hop dot traversal, `group by all`, query DAGs, and page input interpolation is outside the importer.
24+
- Relationship aliases are represented by generated alias models that point at the same physical table as the target model.

docs/native-format.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The native format has two source forms:
77
- YAML semantic project files.
88
- SQL semantic definition files.
99

10-
The native format is the runtime contract. External formats such as LookML, MetricFlow, Hex, Rill, Malloy, Omni, Superset, GoodData, Snowflake Cortex, ThoughtSpot, Holistics, Tableau, AtScale SML, BSL, and Yardstick should be converted into this format by Python importers before they are expected to run through the Rust native runtime.
10+
The native format is the runtime contract. External formats such as LookML, MetricFlow, Hex, Rill, Malloy, Omni, Superset, GoodData, Snowflake Cortex, ThoughtSpot, Holistics, Tableau, AtScale SML, BSL, Yardstick, and Graphene GSQL should be converted into this format by Python importers before they are expected to run through the Rust native runtime.
1111

1212
## Versioning
1313

sidemantic-schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@
11721172
}
11731173
],
11741174
"default": null,
1175-
"description": "Primary key column(s) in related model (defaults to id)",
1175+
"description": "Primary/unique key column(s): related model key for many_to_one, local model key for one_to_many",
11761176
"title": "Primary Key"
11771177
},
11781178
"related_foreign_key": {
@@ -2964,7 +2964,7 @@
29642964
}
29652965
],
29662966
"default": null,
2967-
"description": "Primary key column(s) in related model (defaults to id)",
2967+
"description": "Primary/unique key column(s): related model key for many_to_one, local model key for one_to_many",
29682968
"title": "Primary Key"
29692969
},
29702970
"related_foreign_key": {

0 commit comments

Comments
 (0)