Skip to content

feat: ossie-sql — Calcite engine that executes OSI queries against any JDBC warehouse - #6

Merged
buggtb merged 1 commit into
mainfrom
feature/ossie-sql-engine
Jul 9, 2026
Merged

feat: ossie-sql — Calcite engine that executes OSI queries against any JDBC warehouse#6
buggtb merged 1 commit into
mainfrom
feature/ossie-sql-engine

Conversation

@buggtb

@buggtb buggtb commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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. Takes
    an OSI YAML (path, Reader, inline string, or already-parsed
    OssieDocument) + a JDBC URL + credentials for the warehouse the
    Ossie 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 SQL
    • runtime ms.

Internal (bi.saiku.ossie.sql.internal):

  • OssieSchemaFactory — Calcite SchemaFactory that registers
    Ossie datasets as virtual tables. Now accepts either an
    ossieYaml file path or an ossieDocumentInline YAML string
    operand.
  • OssieSchema, OssieDatasetTable, OssieMetricViewTable,
    OssieRelationshipViewTable — Calcite Table / Schema
    implementations.
  • OssieAutoJoinRule — Calcite RelRule that walks the semantic
    model's relationships block and injects join predicates at plan
    time so queries can name multiple datasets in FROM without
    writing JOIN ... ON ....
  • OssieShelfSqlTranslator — compiles OssieQuery → SQL by walking
    the bi.saiku.ossie.model.SemanticModel DTO tree directly.

Three ways to query

  1. Shelf-state builder (engine.execute(OssieQuery)) — for
    agents, workbench UIs, and code that wants a typed API.
  2. Raw SQL passthrough (engine.executeSql(sql)) — for BI
    query editors, LLMs that write joins directly, or anything that
    speaks SQL.
  3. JDBC connection (engine.openConnection()) — the same
    Calcite JDBC connection under the hood; any tool that speaks
    JDBC gets a semantic-aware surface.

Multi-module layout

ossie-core and ossie-sql now live under a parent pom that
manages 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 an
in-process H2 warehouse seeded with an orders fixture:

  • Simple aggregation (no dimensions) executes and returns typed
    numbers
  • Cross-dataset join (customers × orders) auto-resolves via the
    relationships block — no manual JOIN in the request or the SQL
  • Ratio metric composes SUM(...) / NULLIF(COUNT(*), 0) inline
  • Filter IN excludes rows correctly
  • SQL preview (compile()) works without hitting the warehouse
  • Raw SQL passthrough via executeSql() uses the same schema
  • openConnection() yields a usable JDBC handle
  • Unknown metric names throw with the semantic model name in the
    message
  • Result carries the generated SQL string
  • Column descriptors carry the right type ("dimension" vs
    "metric")

Full suite (34 tests): 34/34 green.

README

New top-level structure listing both modules. Detailed ossie-sql
section with:

  • Quick start dependency block
  • End-to-end example (build engine, build query, execute, print
    records)
  • SQL preview example
  • Raw SQL over the semantic model example
  • What's supported list
  • Warehouse compatibility list

…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.
@buggtb
buggtb merged commit dd71cbb into main Jul 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant