Repository navigation
fix(semantics): accept short LAG and LEAD calls, lateral scopes and lambda parameters - #167
Merged
Merged
Conversation
duckdb_functions() lists each window function once with every parameter, so the catalogue recorded only three-argument LAG and LEAD, and arity checks refused LAG(x), LAG(x, n), LEAD(x) and LEAD(x, n), which DuckDB runs. The extractor now asks the engine which shorter counts each fixed-arity window function binds and records one row per count. Every other window function already matched DuckDB 2.0.0.
…closing items Name resolution gave a derived table that is not LATERAL no enclosing scope, so a derived table nested in a LATERAL subquery could not read the FROM items before that subquery and reported them as unknown aliases. It now reads the enclosing queries, as lineage tracing already does, while only a LATERAL item also reads its left siblings.
A LATERAL item was checked against every FROM item of its level, so its body, and any derived table nested in it, could read items to its right and itself without an error, though engines refuse both. It now reads only the items before it, then the enclosing queries. DuckDB also runs a derived table without LATERAL as lateral when it reads an item before it. Name resolution and lineage now let it do so under DuckDB only; PostgreSQL and the other dialects still refuse it.
The grouping check walked into lambda bodies and reported a lambda's own parameter, such as e in list_filter(ARRAY_AGG(x), lambda e: e <> 'null'), as a column that must be grouped. A parameter is bound only inside its lambda's body, so it is now exempt there, while outer columns in the body and a column of the same name outside the lambda are still checked.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Semantic checks refused DuckDB SQL the engine runs, and missed some errors it refuses:
list_filter(ARRAY_AGG(x), lambda e: e <> 'null'), raised E230 as an ungrouped column.Changes
Verification
cargo test -p sqlquack-semantics --all-featuresmake check-cimake verify-recorded: 0 failed, and no other changes.