[OSSIE][SIGMA] Add bidirectional Sigma Computing data model converter - #297
Open
mattsenicksigma wants to merge 3 commits into
Open
[OSSIE][SIGMA] Add bidirectional Sigma Computing data model converter#297mattsenicksigma wants to merge 3 commits into
mattsenicksigma wants to merge 3 commits into
Conversation
Adds converters/sigma, a hub-and-spoke converter between Sigma Computing data model specs and Apache Ossie, following the same structure/tooling as the dbt and NVIDIA GSF converters (uv, apache-ossie pydantic models). - A real tokenizer/parser/renderer for Sigma's formula language (ossie_sigma.sigma_formula), translating to ANSI SQL where a faithful mapping exists and always preserving the original formula verbatim in a new SIGMA dialect entry for lossless round-tripping. - Sigma <-> OSI mapping for datasets, fields, relationships (including Sigma's two column-addressing schemes), and model-level metrics, with native Sigma ids preserved via custom_extensions for stable re-export. - Controls and named/static filters are intentionally not modeled as OSI concepts (no portable equivalent) but round-trip byte-for-byte via custom_extensions; see converters/sigma/LIMITATIONS.md for this and other documented tradeoffs. - Adds SIGMA to OSIDialect/OSIVendor (python/src/ossie/models.py) and the core-spec schema/docs, plus a Sigma column in the expression_language.md cross-tool mapping tables. - Fixes two small pre-existing gaps found while validating output: core-spec/osi-schema.json was missing root-level dialects/vendors properties already present in the pydantic model, and validation/validate.py didn't skip SQL-syntax checking for the new SIGMA dialect the same way it already does for MDX/TABLEAU/MAQL. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Reviews the Sigma converter against Sigma's documented data-model-as-code spec and fixes the places where it diverged, several of which would have broken a real upload. API-safety fixes: - An expression with no translatable Sigma formula was given an invented `[Dataset/Field]` placeholder (columns) or an empty string (metrics). `formula` is required on both, and the data model API validates the whole document before applying any of it, so one bad formula failed the entire create/update. Untranslatable columns/metrics are now omitted, with an issue naming them. - `_DATATYPE_TO_FORMAT` emitted format kinds (`string`, `integer`, `boolean`, `time`, `datetime`) that do not exist. The spec defines exactly two, `number` and `date`; datatypes with no display format now emit no `format` key at all. The native format object is always preserved, so formatString/currencySymbol/etc. survive. - `schemaVersion` is required on create/update and is now always emitted. Spec coverage: - Preserve unmapped element/column/metric/relationship/model keys by subtraction under a `native` extension rather than an allow-list, so `sort`, `summary`, `groupings`, `columnSecurities`, `visibleAsSource`, `hidden`, `isHighlighted`, `timeline`, `relationshipType` — and fields a future schemaVersion adds — round-trip instead of being dropped. - Handle all six source kinds; `sql`/`table`/`data-model`/`join`/`union` get a readable marker plus the verbatim native source block. - Map `uniqueKeys` to OSIDataset.primary_key, and metric/model `description` to their portable homes. - Drop the `kind: control` framing: the spec has no control element and the create endpoint's element kind enum is `table` only. Renamed the issue to UNSUPPORTED_ELEMENT_KIND as a defensive path, and modeled the real concept, element-level `filters[]`, across all six filter kinds. - Split multi-model handling onto its own EXTRA_MODEL_DROPPED issue instead of reusing the control one. Formula translation: - Render through a sqlglot expression tree instead of hand-built SQL strings, matching how the SQL-native converters here work. Quoting, escaping, and dialect targeting (`to_sql(..., dialect=...)`) come from the library. This caught a silent correctness bug: sqlglot does not re-infer parentheses from tree shape, so `([Qty] + 1) * [Price]` rendered as `"Qty" + 1 * "Price"`. Added an explicit precedence table and tests. - Added DateAdd/DateDiff/Null(), already documented in core-spec/expression_language.md but not implemented. Tests and docs: - Fixtures now cover the documented spec surface: all six filter kinds, all five non-warehouse source kinds, uniqueKeys, groupings, sort, summary, columnSecurities, visibleAsSource, hidden, metric timeline/isHighlighted/ format, relationshipType, both format kinds, and unnamed objects. New fixtureC covers forward compatibility (unknown element kind and unknown keys at every level). - Pin synthesized ids to their literal uuid5 values; comparing two in-process runs could not have caught hash randomization. - 80 tests pass; all three fixtures round-trip byte-identically through the CLI and pass validation/validate.py against the core spec. - LIMITATIONS.md cut to the point, upstream-approval assessment removed, and prose "OSI" replaced with "Ossie". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
mattsenicksigma
marked this pull request as ready for review
August 8, 2026 19:10
Author
|
A more human comment: Looking to add a Sigma Data Model converter to the Ossie standard. I've implemented all required items of the Ossie spec along with some optionals. Some limitations based on Sigma's specific semantic layer will include:
Happy to try and promote convention for these things and/or be a part of talks on promotion of some things to the generic Ossie spec. |
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.
Summary
Adds
converters/sigma, a bidirectional converter between Sigma Computing data model specs and Apache Ossie, following the same structure/tooling as thedbtand NVIDIA GSF converters (uv, theapache-ossiepydantic models).ossie_sigma.sigma_formula), covering ~30 functions and all operators with nested-call support — not a regex classifier. Every expression always preserves the original Sigma formula verbatim in a newSIGMAdialect entry, guaranteeing lossless round-tripping regardless of translation coverage, alongside a best-effortANSI_SQLtranslation.inode-<file>/<PHYSICAL_COLUMN>warehouse references), and model-level metrics, with native Sigma ids preserved viacustom_extensionsso re-export reuses stable ids rather than minting new ones.converters/sigma/LIMITATIONS.md§1) but round-trip byte-for-byte viacustom_extensions.SIGMAtoOSIDialect/OSIVendor(python/src/ossie/models.py), the core-spec schema/docs (core-spec/spec.md,core-spec/osi-schema.json), and a Sigma column inexpression_language.md's cross-tool mapping tables.LIMITATIONS.md):core-spec/osi-schema.jsonwas missing root-leveldialects/vendorsproperties already present in the pydantic model, andvalidation/validate.pydidn't skip SQL-syntax checking forSIGMAthe way it already does forMDX/TABLEAU/MAQL.See
converters/sigma/LIMITATIONS.mdfor a full, honest accounting of design tradeoffs, known gaps (relationship resolution edge cases, table-calculation functions with no portable form, cross-dataset metrics with no Sigma equivalent, etc.), the testing strategy, and a self-assessment of likely review concerns.Opening as a draft to gather early feedback on the approach (particularly the relationship-resolution strategy and the
SIGMAdialect/vendor enum additions) before finalizing.Test plan
cd converters/sigma && uv sync && uv run pytest— 50 tests pass (formula parser unit tests, directional conversion tests, byte-for-byte round-trip tests for two synthetic fixtures, and a real-world-input test againstexamples/tpcds_semantic_model.yaml)sigma-to-osioutput validates cleanly againstcore-spec/osi-schema.jsonandvalidation/validate.pyfor both fixturespython/,converters/dbt/, andconverters/gsf/test suites to confirm the shared enum/schema changes don't regress existing convertersSIGMAenum additions need a dev@ discussion or can proceed via normal PR review (seeLIMITATIONS.md"Assessment: likelihood of upstream approval")🤖 Generated with Claude Code