Repository navigation
Compile measure views and validate measure expressions - #506
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 84df7eda9a
ℹ️ 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".
| aggregate = format!( | ||
| "__sqlctx_decorated_measure({})", |
There was a problem hiding this comment.
Implement the native helpers before emitting calls to them
Queries such as SELECT AGGREGATE(revenue) FILTER (WHERE region = 'west') FROM sales now emit __sqlctx_decorated_measure(...), but the DuckDB extension does not register that function, so the returned SQL fails at database binding rather than executing the measure. Repository-wide search, including hidden files and generated/build-file paths, found only the emitted call, not an implementation or registration. The new window and joined-visibility paths similarly emit undefined __sqlctx_measure_windows and __sqlctx_visible_join helpers. Include the host implementations and registrations with these compiler changes, or lower these operations into executable SQL.
Useful? React with 👍 / 👎.
| if raw_measure_source && !self.rewriter.security_controls { | ||
| if let Some(from) = &mut select.from { | ||
| for source in &mut from.expressions { | ||
| self.source(source)?; |
There was a problem hiding this comment.
Expand declared dimensions on the row-preserving path
For a measure view without visible_source_sql, whose dimension is declared as {"name":"region","sql":"UPPER(region_code)"} over SELECT region_code, amount FROM raw_orders, SELECT region FROM sales takes this path and replaces only the source relation. It returns before the dimension-expansion pass, producing a reference to region against a subquery that exposes only region_code and amount; execution therefore fails with an unknown column. If the source happens to expose a same-named column, it silently returns that column instead of the declared expression. Apply dimension expansion to projections and predicates before returning while preserving the intended ungrouped row semantics.
Useful? React with 👍 / 👎.
Teach the Rust compiler to evaluate declared measures at the caller’s grain. The compiler tracks measure lineage through query scopes, resolves derived references in their owning model, and distinguishes a filtered aggregate from a bare measure. It rejects unsafe reaggregation and reports invalid dependencies in explicitly derived metric declarations.
The catalog and C API expose the measure definitions, compiler diagnostics and explanation data used by the DuckDB extension in the next layer.