Skip to content

Support modern Rill metrics-view fields in import adapter#211

Open
nicosuave wants to merge 8 commits into
mainfrom
update-rill-adapter
Open

Support modern Rill metrics-view fields in import adapter#211
nicosuave wants to merge 8 commits into
mainfrom
update-rill-adapter

Conversation

@nicosuave

Copy link
Copy Markdown
Member

What changed

Brings the Rill import adapter (sidemantic/adapters/rill.py) in line with the current upstream Rill metrics-view parser (rilldata/rill runtime/parser/parse_metrics_view.go). Previously the adapter silently dropped any dimension or measure that lacked an explicit name, ignored several deprecated aliases, and did not understand newer metrics-view sections.

Upstream features now supported

  • Name derivation for unnamed fields. Dimensions without a name now derive it from column (or fall back to dimension_<i>); measures without a name fall back to measure_<i>. This matches Rill's own backwards-compatibility logic instead of dropping the field.
  • property: shorthand. Recognized as the deprecated alias for column: on dimensions.
  • label: alias. Read as the deprecated alias for display_name: on dimensions and measures (previously only display_name was honored).
  • time_comparison measure type. Parsed into a derived calculation with the original Rill type preserved in metadata.
  • Parent / derived metrics views. parent, parent_dimensions, and parent_measures are captured in model metadata so the inheritance linkage survives import.
  • New sections handled gracefully. Measure per:, lookup_table dimensions, and the rollups, ai_instructions, cache, and watermark sections no longer interfere with parsing; lookup_table dimensions are preserved with their lookup config in metadata rather than dropped. ignore: true on a dimension or measure is honored.

Backward compatibility is preserved: all formats and fields the adapter already handled continue to parse identically, and existing Rill fixtures/tests stay green.

Tests and fixtures

  • New fixtures tests/fixtures/rill/parent_metrics.yaml and tests/fixtures/rill/derived_metrics.yaml, with field names verified against the upstream Rill parser.
  • New test module tests/adapters/rill/test_modern_features.py covering aliases, name derivation, time_comparison, per, lookup dimensions, and parent/derived views.
  • Updated existing Rill tests that previously asserted the old drop-on-missing-name behavior to assert the corrected derivation.

Known limitations

  • Rill time_comparison measures are mapped to Sidemantic derived metrics (with the original type recorded in metadata), since Rill does not express the explicit base-metric/comparison wiring that Sidemantic's native time_comparison type requires.
  • A derived (parent) metrics view imports as a metadata-only model; the parent's dimensions/measures are resolved by Rill at a separate layer and are not materialized into the derived model.

Align the Rill adapter with the upstream Rill metrics-view parser:
- Derive dimension/measure names when name is absent (column -> dimension_<i>,
  measure_<i>) instead of dropping them
- Recognize the deprecated property: dimension shorthand alias for column:
- Read the deprecated label: alias for display_name: on dimensions and measures
- Support time_comparison measure type (mapped to derived, original type kept
  in metadata)
- Support parent/derived metrics views (parent, parent_dimensions,
  parent_measures) via model metadata
- Gracefully handle measure per:, lookup_table dimensions, and the
  rollups/ai_instructions/cache/watermark sections
- Honor ignore: true on dimensions and measures
@nicosuave

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a93a481a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/rill.py
A Rill derived metrics view (parent + parent_dimensions/parent_measures
with no own model/table) produced a Model with no table/sql/dax/source_uri,
which validate_model rejects. That broke the CLI import path
(sidemantic validate -> load_from_directory -> add_model) for any Rill
project containing a derived view.

Fall back to the parent metrics-view name as the model table so the
imported model is a valid, queryable representation; meta still records
the parent linkage. Update the non-execution fixture contract to expect
the derived view as a source fragment without own fields.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 84230164a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/rill.py
A parent-only derived view now inherits its selected dimensions/measures
(and the parent's real data source) when the parent metrics view is parsed
in the same project. Previously the derived model was a valid but empty
table, so fields like derived_view.revenue could not be resolved for CLI
info/query. When the parent is absent (single-file parse) the view keeps
the parent-name fallback table and remains valid.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d693f39317

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/rill.py Outdated
Comment thread sidemantic/adapters/rill.py
Comment thread sidemantic/adapters/rill.py
…ime defaults

- Normalize parent_dimensions/parent_measures selector forms: '*' and omitted
  select all, lists select by name, and exclude/regex mappings are honored.
  Previously a '*' selector was iterated as characters, dropping all fields.
- Map Rill time_comparison measures to Sidemantic's native time_comparison
  (base_metric + prior_period) so they query as real period-over-period
  comparisons instead of silently resolving to the current-period value.
- Inherit the parent's default time dimension/grain (and materialize the
  referenced time dimension) on derived views that omit their own timeseries.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47aff5984e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/rill.py
Comment thread sidemantic/adapters/rill.py
Comment thread sidemantic/adapters/rill.py Outdated
…ld grain

- When a derived view selects a derived/ratio parent measure, also inherit the
  parent measures it references as hidden (public=False) fields so formulas like
  'revenue / orders' resolve on the child.
- Support DuckDB-style 'expr' / string star selectors ('* EXCLUDE (...)') in
  parent_dimensions/parent_measures instead of falling through to select-all.
- Preserve a child-only smallest_time_grain override when inheriting the
  parent's timeseries, rather than overwriting it with the parent grain.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a32ee1279f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/rill.py
Comment thread sidemantic/adapters/rill.py
Comment thread sidemantic/adapters/rill.py
Resolve test_fixture_functionality_contracts.py: re-apply the three rill
contract changes onto main's reorganized sets -- derived_metrics.yaml belongs in
EXPECTED_LOW_SIGNAL_FIXTURES (one field-less model, not an empty graph), and
RillAdapter joins source_fragments_without_fields and semantic_only_no_sources.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f61e9aaf48

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/rill.py Outdated
A Rill measure with per: or requires: was unconditionally promoted to a
derived metric. When the expression is an ordinary aggregation (e.g.
SUM(amount)), promoting it to derived leaves the raw aggregate as the
outer formula while the CTE only projects the decomposed column. That
generates invalid SQL whenever a source column name also exists as a
measure name (Binder error referencing the raw column).

Only promote per/requires measures to derived when the expression is not
itself a single top-level aggregation; otherwise keep simple aggregate
parsing so it decomposes to agg/sql and stays queryable. The per/requires
linkage is still preserved in metadata.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 88b86c231a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/rill.py
A Rill derived metrics view (parent: ...) may only select inherited
parent fields via parent_dimensions/parent_measures; Rill's own
validation rejects a derived view that defines its own dimensions or
measures. The importer now fails loudly in that case instead of parsing
the child fields and exposing non-existent columns against the parent
table.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6688eb567c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/rill.py
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