Skip to content

Reference implementation for rewriting Layer 2 and Layer 3 queries #707

Open

Description

@vigneshc

Relational Semantics and Wide table semantics merged recently.

A reference implementation that takes queries in these layers, and convert them to regular SQL is useful for multiple reasons, including i) More concrete specification compared to examples & tests ii) Can be used as a standalone library, for building an ossie engine.

Discussion on this here.

Activity

  1. vigneshc commented on Nov 8, 2026

    @vigneshc
    Author

    @christianeu-db , created this for further discussions and tracking.

  2. christianeu-db commented on Nov 9, 2026

    @christianeu-db
    Contributor

    Thanks #502's expander should cover a reference impl for Layer 2. Will keep this item open to track Layer 3 tests / expanders

  3. ekut commented on Nov 17, 2026

    @ekut
    Contributor

    @christianeu-db listed four next steps in the review of #716. For the Layer 3 part of this issue, I propose to finish them in three more PRs:

    1. Expected results in the .ost table format, with the case notes in compliance/wide_table/cases/README.md: done in test(compliance): write wide table expected results as ost tables #741.
    2. A query.ossie.sql for each case in compliance/wide_table/cases that returns rows (a01 to a21). It holds the Layer 2 query of the case's Section 5 lowering. The 25 error cases have no Layer 2 query, so they get none.
    3. A Layer 3 lowering that turns query.json and the model into that Layer 2 query, or into a Section 8 error.
    4. Running the cases in .ost, once View expander #502 lands and ost can load the retail and stores fixtures.

    I'm working on (2). One question before anyone starts (3): should it live in ost/ next to the expander, or in a separate library, as this issue suggests?

    I wrote the Layer 2 queries of a few cases by hand and expanded them with the 502-expander branch (f91b5a5), then ran them on DuckDB. a01, a02, a07 and a08 return the expected rows. Two kinds of case need what the expander does not support yet:

    • a12 has dimensions from orders and customers and no metric. Its query joins two relations of a model without AGG(), and the expander stops with "view expander does not support measures through a join yet".
    • a16, a19, a20 and a21 use date_dim.year, whose expression is d_year. On a19 the expander stops with "view expander does not support field expressions yet: year".
  4. christianeu-db commented on Nov 19, 2026

    @christianeu-db
    Contributor

    @ekut fyi, #502 is currently in review in #769

  5. ekut commented on Nov 22, 2026

    @ekut
    Contributor

    With #769 merged, I'm starting on (3) and (4). The lowering will live in ost next to the expander, because its output is the expander's input. I plan two PRs:

    1. The retail and stores fixtures, an ost function that runs a Layer 3 query through the lowering and the expander, and the cases that return rows as .ost scripts.
    2. The 25 error cases as .ost scripts, each expecting its Section 8 code.

    On main (83d39d6), 16 of the 21 query.ossie.sql files expand and return the rows of expected.txt. The other five still stop on the two gaps from my comment above (a12, and a16, a19, a20, a21). The first PR will list them as pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue needs triage by a maintainer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions