Skip to content

Auto preagg widgets and inline SQL metrics#60

Merged
nicosuave merged 3 commits intomainfrom
nicosuave/sidemantic-anywidget
Jan 10, 2026
Merged

Auto preagg widgets and inline SQL metrics#60
nicosuave merged 3 commits intomainfrom
nicosuave/sidemantic-anywidget

Conversation

@nicosuave
Copy link
Copy Markdown
Member

Summary:

  • auto-materialize widget preaggregations from query intents
  • allow inline SQL aggregate metrics without explicit agg
  • update widget demo notebook with auto-preagg example

Tests:

  • uv run ruff format --check . --exclude docs/_extensions --exclude sidemantic-duckdb/extension-ci-tools --exclude sidemantic-duckdb/scripts --exclude sidemantic-duckdb/duckdb --exclude sidemantic/adapters/malloy_grammar

Copy link
Copy Markdown

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

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: 8d3fbdf256

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread sidemantic/validation.py
Comment on lines +88 to +89
if measure.agg is None and measure.sql and _sql_has_aggregation(measure.sql):
continue
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard inline-agg SQL that uses unqualified columns

Allowing measure.agg is None when _sql_has_aggregation() is true means metrics like sql: "SUM(price) / SUM(cost)" now pass validation, but SQLGenerator._extract_metric_filter_columns only adds columns to the model CTE when they are table-qualified (it checks col.table), so unqualified price/cost references are skipped and the generated query will hit missing-column errors when it runs. This only happens for inline-aggregate SQL that doesn’t use {model}./qualified column names; consider enforcing qualification here or broadening column extraction to include unqualified column references for these metrics.

Useful? React with 👍 / 👎.

@nicosuave nicosuave force-pushed the nicosuave/sidemantic-anywidget branch from cf77a33 to d505ae0 Compare January 10, 2026 00:04
@nicosuave nicosuave merged commit 2346527 into main Jan 10, 2026
10 checks passed
@nicosuave nicosuave deleted the nicosuave/sidemantic-anywidget branch January 10, 2026 00:19
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