Skip to content

Fix yardstick rewriter for LookML-loaded models with {model} placeholder#106

Merged
nicosuave merged 1 commit intomainfrom
nicosuave/yardstick-model-placeholder-fix
Feb 25, 2026
Merged

Fix yardstick rewriter for LookML-loaded models with {model} placeholder#106
nicosuave merged 1 commit intomainfrom
nicosuave/yardstick-model-placeholder-fix

Conversation

@nicosuave
Copy link
Member

The LookML adapter stores dimension/measure SQL with {model} placeholders (replacing ${TABLE}). The standard query rewriter handles this, but the yardstick rewriter passed these directly to sqlglot.parse_one(), which choked on the curly braces producing invalid SQL like {'_0': table.model}.

Fixes:

  • Replace {model} in dimension SQL before parsing (5 call sites)
  • Skip dimension expansion when resolved SQL is just table.column (prevents unqualified outer references in correlation predicates)

The LookML adapter stores dimension/measure SQL with {model} placeholders
(replacing ${TABLE}). The standard query rewriter handles this, but the
yardstick rewriter passed these directly to sqlglot.parse_one(), which
choked on the curly braces producing invalid SQL like {'_0': table.model}.

Fixes:
- Replace {model} in dimension SQL before parsing (5 call sites)
- Skip dimension expansion when resolved SQL is just table.column
  (prevents unqualified outer references in correlation predicates)
@nicosuave nicosuave merged commit ec4c6a6 into main Feb 25, 2026
10 of 12 checks passed
@nicosuave nicosuave deleted the nicosuave/yardstick-model-placeholder-fix branch February 25, 2026 14:52
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: 856dd9cba1

ℹ️ 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 +995 to +996
if dimension_sql.lower() == f'{table_alias}.{column.name}'.lower():
return None

Choose a reason for hiding this comment

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

P1 Badge Preserve alias-qualified dimensions for multi-model Yardstick

Returning None when a resolved dimension SQL is exactly <alias>.<column> leaves the original (often unqualified) column in place, but multi-model Yardstick context building skips unqualified group expressions (_build_yardstick_context_dimensions drops them when not tables and not single_model_scope). In joined semantic-model queries, a LookML dimension like {model}.region can therefore stop generating correlation predicates, causing AGGREGATE(...) subqueries to evaluate at the wrong grain (totals instead of per-dimension values).

Useful? React with 👍 / 👎.

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