Skip to content

feat(meerkat-core): recognise FROM-side column aliases (AS t(v), UNNEST, joins, VALUES) in the alias walker#296

Merged
shriram-devrev merged 1 commit into
mainfrom
SURFF-1305-from-side-alias
Jul 14, 2026
Merged

feat(meerkat-core): recognise FROM-side column aliases (AS t(v), UNNEST, joins, VALUES) in the alias walker#296
shriram-devrev merged 1 commit into
mainfrom
SURFF-1305-from-side-alias

Conversation

@shashwat-devrev

@shashwat-devrev shashwat-devrev commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Issue: https://app.devrev.ai/devrev/issue/SURFF-1305

ensureParsedExpressionAlias prefixes bare column references with the owning table name so downstream binding is unambiguous under joins. Its scope-tracking set previously covered only lambda-bound identifiers. Anything else bare got rewritten. FROM-clause bindings (AS t(v) on subqueries, UNNEST(...) AS t(v), join binders, PIVOT, VALUES ... AS t(a, b, c), base-table column aliases) were invisible to the walker. Any bare identifier that matched a FROM-side alias got the outer-table prefix applied, turning valid SQL into a binder error.

What is fixed?

Consumers emitting DuckDB SQL through meerkat can't safely use column-aliased FROM clauses. Concretely, the correlated-scalar-subquery pattern for aggregating an array-typed column:
(SELECT avg(v) FROM UNNEST(any_value(list_transform(surveys_aggregation, x -> x.average))) AS t(v))
gets rewritten to:
(SELECT avg(ticket.v) FROM UNNEST(any_value(list_transform(surveys_aggregation, x -> x.average))) AS t(v))
DuckDB then rejects:
Binder Error: Values list "ticket" does not have a column named "v"

Relevant PR: #298 Bump meerkat node

@github-actions

Copy link
Copy Markdown

⚠️ Heads-up: This repository will be blocked from any work other than patching.

File meerkat-core/src/utils/ensure-sql-expression-column-alias.spec.ts is not allowed to be modified in this patch.
The following vulnerability issues are past SLA:

Note that there is significant latency in updating this list. Please reach out on #antifragile if you are in a hurry or have an emergency.

@shashwat-devrev shashwat-devrev changed the title feat(meerkat-core): handle from side aliasing feat(meerkat-core): recognise FROM-side column aliases (AS t(v), UNNEST, joins, VALUES) in the alias walker Jul 13, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Heads-up: This repository will be blocked from any work other than patching.

File meerkat-core/src/utils/ensure-sql-expression-column-alias.spec.ts is not allowed to be modified in this patch.
The following vulnerability issues are past SLA:

Note that there is significant latency in updating this list. Please reach out on #antifragile if you are in a hurry or have an emergency.

@shriram-devrev shriram-devrev merged commit 47baa4e into main Jul 14, 2026
4 of 6 checks passed
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.

3 participants