Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70234b20b2
ℹ️ 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".
| parsed = sqlglot.parse_one(filter_sql, dialect=self.dialect) | ||
| except Exception: | ||
| return filter_sql | ||
|
|
||
| for col in parsed.find_all(exp.Column): | ||
| if not col.table: | ||
| col.set("table", model_alias) |
There was a problem hiding this comment.
Avoid qualifying columns inside subqueries
This blanket qualification rewrites every unqualified column, including ones inside subqueries. For segment SQL like id IN (SELECT id FROM other_table), the inner id is now forced to model_alias.id, which can make the subquery invalid or change its semantics (it no longer refers to other_table.id). This only happens when segment filters include subqueries or unqualified inner columns, but it will silently corrupt those filters. Consider limiting qualification to the top-level scope or skipping columns within nested SELECTs.
Useful? React with 👍 / 👎.
Qualifies unaliased columns in segment filters so they push down into model CTEs. Adds a regression test for count_distinct with a segment lacking a {model} placeholder.