Skip to content

Add Yardstick adapter and SQL rewrite parity#104

Merged
nicosuave merged 5 commits intomainfrom
nicosuave/yardstick-parity3
Feb 25, 2026
Merged

Add Yardstick adapter and SQL rewrite parity#104
nicosuave merged 5 commits intomainfrom
nicosuave/yardstick-parity3

Conversation

@nicosuave
Copy link
Member

This adds Yardstick as a first-class adapter and expands SQL rewriting to cover nuanced Yardstick measure semantics, including AGGREGATE and AT forms. It updates validation, loader, dependency, generator, and aggregation detection paths so Yardstick models resolve through the same semantic pipeline. It ports the Yardstick replay fixture set and adds targeted rewriter regressions, including strict=false passthrough and default-alias scoping fixes. Local checks passed with ruff check, ruff format --check, and pytest -v (3131 passed).

Copy link

@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: e1e9fa6877

ℹ️ 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 on lines +335 to +336
for column in select_scope.find_all(exp.Column)
if not column.table and column.name in placeholder_names

Choose a reason for hiding this comment

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

P1 Badge Restrict placeholder detection to current SELECT scope

_rewrite_yardstick_select_scope collects initial_placeholders with select_scope.find_all(exp.Column), which traverses nested subqueries/CTEs, so an outer query like SEMANTIC SELECT * FROM (SELECT AGGREGATE(revenue) FROM sales_v) s sees inner placeholders but has no semantic model in its own FROM and then raises Yardstick query must reference at least one known semantic model in FROM/JOIN. This breaks valid Yardstick queries that use subqueries, even though subquery support exists in the non-Yardstick rewrite path.

Useful? React with 👍 / 👎.

dim = model.get_dimension(col_name)
if dim:
dim_sql = replace_model_placeholder(dim.sql_expr)
select_cols.append(f"{dim_sql} AS {col_name}")

Choose a reason for hiding this comment

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

P2 Badge Quote generated column aliases in metric SQL column injection

When injecting extra columns for inline-aggregate metric SQL, aliases are emitted as AS {col_name} without quoting, unlike the previous implementation. If a referenced source column is a reserved word or needs quoting (for example, order), generated CTE SQL becomes invalid or resolves to the wrong identifier, causing otherwise valid metrics with inline aggregates to fail at execution time.

Useful? React with 👍 / 👎.

@nicosuave nicosuave merged commit cf241dc into main Feb 25, 2026
15 checks passed
@nicosuave nicosuave deleted the nicosuave/yardstick-parity3 branch February 25, 2026 13:16
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