Skip to content

fix(sql): an unaliased window call is named as its projection names it - #486

Draft
EnRaiha wants to merge 2 commits into
NodeDB-Lab:mainfrom
EnRaiha:fix/f19a-unaliased-window-alias
Draft

EnRaiha wants to merge 2 commits into
NodeDB-Lab:mainfrom
EnRaiha:fix/f19a-unaliased-window-alias

Conversation

@EnRaiha

@EnRaiha EnRaiha commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

SELECT ROW_NUMBER() OVER (ORDER BY id) FROM t answered 42883 function row_number() does not exist. The window spec named the item by its printed text, and the projection named it by that text in lower case. The two names never matched, so the window column fell through to the scalar evaluator. The window spec now lowers the text too, as the projection does.

`SELECT ROW_NUMBER() OVER (ORDER BY id) FROM t` answered
`42883 function row_number() does not exist`. The window spec named the item
by its printed text, and the projection named it by that text in lower case.
The two names never matched, so the window column fell through to the scalar
evaluator. The window spec now lowers the text too, as the projection does.
unaliased_item_name (nee a bare .to_lowercase() on the formatted
expression) folded a string literal's own case along with everything
else. Two unaliased items differing only by a quoted literal
(tag = 'A' vs tag = 'a') collapsed onto the same generated name, even
though Value::String equality is case-sensitive -- the two compute
different values. HashMap-keyed row insertion then let the second
window spec's write silently overwrite the first's: both output
columns reported the second window's value, the first lost with no
error.

unaliased_item_name now walks the rendered text and folds everywhere
except inside a single-quoted span, tracking SQL's '' escape so an
escaped quote never toggles out of the literal early. The one function
now serves both call sites (select/helpers.rs's own projections and
window/extract.rs's window specs), keeping them on the same name for
the original bug (an unaliased window call's column must match its
projection) without re-introducing this one.

This branch has not been deployed

No deployments
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