feat: ossie-sql — Calcite engine that executes OSI queries against any JDBC warehouse - #6
Merged
Merged
Conversation
…y JDBC warehouse
Adds a second module alongside ossie-core:
- OssieEngine (builder pattern, AutoCloseable) — top-level API that
takes an OSI YAML + a JDBC URL for any warehouse and provides
three query surfaces:
1. Shelf-state queries via OssieQuery / OssieResult
2. Raw SQL over the semantic model via executeSql()
3. A plain JDBC Connection via openConnection() — any tool that
speaks JDBC gets a semantic-aware surface
- OssieShelfSqlTranslator (internal) — compiles OssieQuery to SQL by
walking bi.saiku.ossie.model.SemanticModel directly. Handles
aggregation overrides on metrics (including preserving COUNT(*)
when the override isn't COUNT), field-expression rewrites
(agent-friendly names → raw columns), filter operators, sorts,
limits.
- OssieSchemaFactory / OssieSchema / OssieDatasetTable /
OssieMetricViewTable / OssieRelationshipViewTable /
OssieAutoJoinRule — Calcite adapter internals. SchemaFactory now
accepts either an ossieYaml file path or an ossieDocumentInline
YAML string.
Restructures the repo:
- Parent pom manages shared versions (Jackson, Calcite, JUnit, Guava,
H2)
- ossie-core stays untouched behaviour-wise, moves into ossie-core/
subdir
- New ossie-sql module depends on ossie-core + calcite-core
10 new end-to-end tests in OssieEngineTest, run against an
in-process H2 warehouse:
- Simple aggregation
- Cross-dataset join auto-resolves via relationships block
- Ratio metric composes SUM/NULLIF inline
- Filter IN excludes rows
- SQL preview via compile()
- Raw SQL passthrough via executeSql()
- openConnection() returns a usable JDBC handle
- Unknown metric names throw with semantic model in message
- Result carries generated SQL
- Column descriptors typed correctly
Full suite: 34/34 (24 ossie-core + 10 ossie-sql).
README extended with an ossie-sql section covering the API, three
query surfaces, and warehouse compatibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restructures the repo into a parent + two child modules and adds
ossie-sql — a Calcite adapter + shelf-state query engine that
executes queries authored against an OSI semantic model against any
JDBC warehouse.
What's new
ossie-sql module
Public API (
bi.saiku.ossie.sql):OssieEngine— top-level, builder-pattern entry point. Takesan OSI YAML (path, Reader, inline string, or already-parsed
OssieDocument) + a JDBC URL + credentials for the warehouse theOssie datasets are backed by.
AutoCloseable.OssieQuery— immutable shelf-state request. Builder methods:.model()/.factDataset()/.rows()/.columns()/.values()(with optional aggregation override) /.filter()/.sortByMetric()/.sortByField()/.limit().OssieResult— records + column descriptors + generated SQLInternal (
bi.saiku.ossie.sql.internal):OssieSchemaFactory— CalciteSchemaFactorythat registersOssie datasets as virtual tables. Now accepts either an
ossieYamlfile path or anossieDocumentInlineYAML stringoperand.
OssieSchema,OssieDatasetTable,OssieMetricViewTable,OssieRelationshipViewTable— CalciteTable/Schemaimplementations.
OssieAutoJoinRule— CalciteRelRulethat walks the semanticmodel's
relationshipsblock and injects join predicates at plantime so queries can name multiple datasets in
FROMwithoutwriting
JOIN ... ON ....OssieShelfSqlTranslator— compilesOssieQuery→ SQL by walkingthe
bi.saiku.ossie.model.SemanticModelDTO tree directly.Three ways to query
engine.execute(OssieQuery)) — foragents, workbench UIs, and code that wants a typed API.
engine.executeSql(sql)) — for BIquery editors, LLMs that write joins directly, or anything that
speaks SQL.
engine.openConnection()) — the sameCalcite JDBC connection under the hood; any tool that speaks
JDBC gets a semantic-aware surface.
Multi-module layout
ossie-coreandossie-sqlnow live under a parent pom thatmanages shared versions (Jackson, Calcite, JUnit, Guava, etc.).
Each child module has its own release lifecycle but ships in the
same repo + one CI matrix.
Tests
10 new tests in
OssieEngineTest— real end-to-end against anin-process H2 warehouse seeded with an orders fixture:
numbers
relationships block — no manual JOIN in the request or the SQL
SUM(...) / NULLIF(COUNT(*), 0)inlinecompile()) works without hitting the warehouseexecuteSql()uses the same schemaopenConnection()yields a usable JDBC handlemessage
type("dimension" vs"metric")
Full suite (34 tests): 34/34 green.
README
New top-level structure listing both modules. Detailed ossie-sql
section with:
records)