From 2cad98438d454a854adfc6022a5eafef0ecd5f66 Mon Sep 17 00:00:00 2001 From: Kevin Longe <273747162+kvlonge@users.noreply.github.com> Date: Fri, 13 Nov 2026 04:51:42 +0000 Subject: [PATCH 1/2] chore(deps): pin SQLClean 0.9.4 and SQLQuack 0.11.1 --- Cargo.lock | 68 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 24 +++++++++---------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f49af2ac3f..5f3fa34453 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4525,8 +4525,8 @@ dependencies = [ [[package]] name = "sqlclean" -version = "0.9.2" -source = "git+https://github.com/sqlstack-io/sqlclean.git?rev=3b9cc0aa426cfbfb098c8e3a75231388e9a6115c#3b9cc0aa426cfbfb098c8e3a75231388e9a6115c" +version = "0.9.4" +source = "git+https://github.com/sqlstack-io/sqlclean.git?rev=e54722c91fb36b34f13508d8ec503255f0d76920#e54722c91fb36b34f13508d8ec503255f0d76920" dependencies = [ "rayon", "rustc-hash", @@ -4543,8 +4543,8 @@ dependencies = [ [[package]] name = "sqlquack-derive" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "proc-macro2", "quote", @@ -4553,8 +4553,8 @@ dependencies = [ [[package]] name = "sqlquack-diagnostics" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "serde", "serde_json", @@ -4563,8 +4563,8 @@ dependencies = [ [[package]] name = "sqlquack-fingerprint" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "sha2 0.10.9", "sqlquack-parse", @@ -4573,8 +4573,8 @@ dependencies = [ [[package]] name = "sqlquack-format" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "serde_json", "sqlquack-parse", @@ -4583,8 +4583,8 @@ dependencies = [ [[package]] name = "sqlquack-lint" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "rayon", "rustc-hash", @@ -4596,8 +4596,8 @@ dependencies = [ [[package]] name = "sqlquack-parse" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "sqlquack-syntax", "sqlquack-syntax-bigquery", @@ -4609,8 +4609,8 @@ dependencies = [ [[package]] name = "sqlquack-semantics" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "regex", "rustc-hash", @@ -4625,8 +4625,8 @@ dependencies = [ [[package]] name = "sqlquack-syntax" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "serde", "serde_json", @@ -4638,8 +4638,8 @@ dependencies = [ [[package]] name = "sqlquack-syntax-bigquery" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "sqlquack-syntax", "stacker", @@ -4647,8 +4647,8 @@ dependencies = [ [[package]] name = "sqlquack-syntax-clickhouse" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "sqlquack-syntax", "stacker", @@ -4656,8 +4656,8 @@ dependencies = [ [[package]] name = "sqlquack-syntax-databricks" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "sqlquack-syntax", "stacker", @@ -4665,8 +4665,8 @@ dependencies = [ [[package]] name = "sqlquack-syntax-duckdb" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "sqlquack-syntax", "stacker", @@ -4674,8 +4674,8 @@ dependencies = [ [[package]] name = "sqlquack-syntax-postgres" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "sqlquack-syntax", "stacker", @@ -4683,8 +4683,8 @@ dependencies = [ [[package]] name = "sqlquack-syntax-snowflake" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "serde", "serde_json", @@ -4696,8 +4696,8 @@ dependencies = [ [[package]] name = "sqlquack-syntax-sqlite" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "sqlquack-syntax", "stacker", @@ -4705,8 +4705,8 @@ dependencies = [ [[package]] name = "sqlquack-syntax-sqlserver" -version = "0.10.0" -source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373#31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" +version = "0.11.1" +source = "git+https://github.com/sqlstack-io/sqlquack.git?rev=62642bc1698556cbec80a0ee2ae24bb63ac7607f#62642bc1698556cbec80a0ee2ae24bb63ac7607f" dependencies = [ "sqlquack-syntax", "stacker", diff --git a/Cargo.toml b/Cargo.toml index f30264860e..0bedcfd35e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -176,22 +176,22 @@ sqlbuild-scopes = { path = "crates/sqlbuild-scopes" } sqlbuild-sqltext = { path = "crates/sqlbuild-sqltext" } sqlbuild-state = { path = "crates/sqlbuild-state" } # SQL lint Rules, quality Rules and the formatter. -sqlclean = { git = "https://github.com/sqlstack-io/sqlclean.git", rev = "3b9cc0aa426cfbfb098c8e3a75231388e9a6115c" } +sqlclean = { git = "https://github.com/sqlstack-io/sqlclean.git", rev = "e54722c91fb36b34f13508d8ec503255f0d76920" } # SQL change fingerprints over SQLQuack's tokenizers. -sqlquack-fingerprint = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373", features = ["bigquery", "databricks", "duckdb", "postgres", "snowflake", "sqlite", "sqlserver"] } +sqlquack-fingerprint = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "62642bc1698556cbec80a0ee2ae24bb63ac7607f", features = ["bigquery", "databricks", "duckdb", "postgres", "snowflake", "sqlite", "sqlserver"] } # Scopes, name resolution, types and lineage for the native analysis route. -sqlquack-semantics = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373", features = ["bigquery", "clickhouse", "databricks", "duckdb", "postgres", "snowflake", "sqlite", "sqlserver"] } +sqlquack-semantics = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "62642bc1698556cbec80a0ee2ae24bb63ac7607f", features = ["bigquery", "clickhouse", "databricks", "duckdb", "postgres", "snowflake", "sqlite", "sqlserver"] } # SQLQuack's Snowflake-family parser and tokenizer, reached as SQLQuack exposes them. -sqlquack-parse = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" } +sqlquack-parse = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "62642bc1698556cbec80a0ee2ae24bb63ac7607f" } # SQLQuack's syntax tree and lossless tokens. -sqlquack-syntax = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" } -sqlquack-syntax-bigquery = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" } -sqlquack-syntax-clickhouse = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" } -sqlquack-syntax-databricks = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" } -sqlquack-syntax-duckdb = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" } -sqlquack-syntax-postgres = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" } -sqlquack-syntax-sqlite = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" } -sqlquack-syntax-sqlserver = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "31a8bb1052ecff7b5a5d3175a8e2f64f1f97a373" } +sqlquack-syntax = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "62642bc1698556cbec80a0ee2ae24bb63ac7607f" } +sqlquack-syntax-bigquery = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "62642bc1698556cbec80a0ee2ae24bb63ac7607f" } +sqlquack-syntax-clickhouse = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "62642bc1698556cbec80a0ee2ae24bb63ac7607f" } +sqlquack-syntax-databricks = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "62642bc1698556cbec80a0ee2ae24bb63ac7607f" } +sqlquack-syntax-duckdb = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "62642bc1698556cbec80a0ee2ae24bb63ac7607f" } +sqlquack-syntax-postgres = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "62642bc1698556cbec80a0ee2ae24bb63ac7607f" } +sqlquack-syntax-sqlite = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "62642bc1698556cbec80a0ee2ae24bb63ac7607f" } +sqlquack-syntax-sqlserver = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "62642bc1698556cbec80a0ee2ae24bb63ac7607f" } stacker = "0.1" syn = { version = "2", features = ["full", "visit", "extra-traits"] } subtle = "2" From 4e15ae91ae1310c3a5e402c4183237276d6280db Mon Sep 17 00:00:00 2001 From: Kevin Longe <273747162+kvlonge@users.noreply.github.com> Date: Fri, 13 Nov 2026 05:41:29 +0000 Subject: [PATCH 2/2] test(duckshop): add an edge case for relations aliased first and last A bare FIRST or LAST after a joined relation is its alias. The case joins one relation aliased with AS and one without, and checks on Snowflake that each alias names its own relation. --- benchmarks/duckshop/README.md | 6 +-- .../int_edge_first_last_aliases.sql | 42 +++++++++++++++ .../test_int_edge_first_last_aliases.sql | 53 +++++++++++++++++++ 3 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 benchmarks/duckshop/project/models/intermediate/edge_cases/int_edge_first_last_aliases.sql create mode 100644 benchmarks/duckshop/project/tests/unit/intermediate/edge_cases/test_int_edge_first_last_aliases.sql diff --git a/benchmarks/duckshop/README.md b/benchmarks/duckshop/README.md index bbb29e1669..4809449ba4 100644 --- a/benchmarks/duckshop/README.md +++ b/benchmarks/duckshop/README.md @@ -124,8 +124,8 @@ project and does not change it: `edge_running_peaks`, that a pre-hook of `int_edge_basket_running_peaks` creates (`models/intermediate/edge_cases/_sqlbuild/_hooks/sql/`) and SQLBuild does not declare. -It has 166 models (13 staging, 139 intermediate, 14 marts), 5 Python functions, a SQL table -function, a hook-created JavaScript function, 191 unit tests and 4 scenarios, in nine groups: +It has 167 models (13 staging, 140 intermediate, 14 marts), 5 Python functions, a SQL table +function, a hook-created JavaScript function, 192 unit tests and 4 scenarios, in nine groups: | Group | Covers | |-------|--------| @@ -134,7 +134,7 @@ function, a hook-created JavaScript function, 191 unit tests and 4 scenarios, in | VARIANT comparisons | `ARRAY_MAX`, `ARRAY_MIN` and `ARRAY_REVERSE` over arrays mixing numbers, strings, booleans, JSON nulls and integers past 2^53; `MAX` across kinds and non-ASCII strings; `=` and `EQUAL_NULL` for `1`, `"1"` and `1.0`, reordered keys, JSON null and DATE or TIMESTAMP values held in a `VARIANT` against their text; `MIN_BY` and `MAX_BY` of `VARIANT` values; `PARTITION BY`, `SELECT DISTINCT` and `ARRAY_AGG(DISTINCT)` over `VARIANT`; JSON nulls in `ARRAY_REMOVE`, `ARRAY_DISTINCT` and `ARRAYS_OVERLAP`; decimals with trailing zeros in `ARRAY_CONTAINS` and `ARRAY_POSITION`; `OBJECT_CONSTRUCT(* EXCLUDE ("note"))` | | Dates and times | `TRY_TO_TIMESTAMP_NTZ` and its siblings over free text; epoch milliseconds as numbers and text; daylight-saving gaps and overlaps; fractional offsets; nanosecond truncation and epoch parts after 2242; pre-1970 text with sub-microsecond digits; date-part normalisation; month ends and leap days; week numbering across a year; sentinel timestamps; `TRY_TO_DATE` with numeric and month-name formats over unpadded fields, two-digit years, ISO `T` and `Z`, trailing letters, a long s, mixed separators and runs of spaces; text read as `TIMESTAMP_TZ` and `TIMESTAMP_LTZ` with `T`, `Z`, `+00:00`, `+0000`, `+09:00` and `-05:30`, back as the UTC instant, date, year and day start, and compared with text, `TIMESTAMP_NTZ` and `DATE`; `FIRST_VALUE` of a zoned value as a `DATE`; `DATEADD` and `TIMEADD` on `TIME(3)` and the type they return; `DATEDIFF` across units; `TIME(9)`, `FF3` and bare `FF` formats truncating; `DATE`, `TO_TIME`, `TRY_TO_TIMESTAMP` and `TO_TIMESTAMP_LTZ` of clock text, and `CURRENT_DATE` and `SYSDATE` read only for facts that hold on any day | | Ordering, numbers and text | NULL ordering under `DESC`; ties in ordered aggregates, `MAX_BY`, `MODE` and `ANY_VALUE`; default window frames; `UNION ALL BY NAME`; `ROUND` half-way values, decimal division, `MOD` and 38-digit amounts; integers past 2^53 against `FLOAT`; regular expressions and backslash escapes; `LIKE ... ESCAPE` and `ILIKE ANY`; `SPLIT_PART` and `SUBSTR` before the start; `NOT IN` with a NULL; names in many scripts; `JOIN ... USING` between `NUMBER(18,0)`, `NUMBER(38,0)` and text keys, with the types of the merged and qualified keys; NULL arithmetic and the types of NULL, decimal and exponent literals, `COUNT`, `ROW_NUMBER`, `%` and `NULLIF`; `MEDIAN` at scales 0 to 15; `DIV0` by literal zeros; `MODE`, `MEDIAN` and `COUNT_IF` over no rows; aggregates inside window functions and `QUALIFY`; `ROLLUP` totals; `TRUNC` of `FLOAT`; infinity words in other scripts; `CASE` without `ELSE` and `DECODE` over text; regular expressions with a `?` after a lazy quantifier, classes opening with `]`, empty matches and `.` against a carriage return; case-insensitive matches outside ASCII; `ILIKE` with a long s; `JAROWINKLER_SIMILARITY` of accented names in both cases; Base64 text with line feeds; `STARTSWITH`, `ENDSWITH`, `SUBSTRING`, `POSITION` with `IN` and with a comma, `CHARINDEX`, `CHR`, `REGEXP_SUBSTR_ALL`, `::STRING` and `CAST ... AS STRING`; `HEX_ENCODE`, `HEX_DECODE_STRING`, `TRY_HEX_DECODE_STRING` and `TRY_BASE64_DECODE_BINARY`; a comment attached to a text literal; `FLOOR` with and without a scale, `BITAND`, `ZEROIFNULL`, `::BIGINT` and `::DOUBLE`; `IS NOT DISTINCT FROM` and `EQUAL_NULL`; a comma join after an explicit join; `HASH_AGG` read in two row orders | -| Lineage and analysis | clauses whose columns decide rows without being output (`WHERE`, `QUALIFY`, `GROUP BY` by position and `ALL`, `ORDER BY` under `LIMIT`, `EXISTS`, a `FLATTEN` input, `ROLLUP` by position, `EXCEPT` under `LIMIT`); `RIGHT JOIN ... USING`, `NATURAL JOIN`, a `USING` key under a later outer join, and unmatched `ASOF JOIN` rows; `CONNECT BY` beside a column named `level`; a recursive CTE without `RECURSIVE` whose columns shift per iteration; `LAST_DAY` with a date part; positional columns and the names Snowflake gives unaliased expressions; `TEXT(5)` and widened `COUNT` contracts; `LAG` and `LEAD` with one, two and three arguments; a comma-joined `LATERAL` whose nested derived table reads the left item; untyped and typed `FILTER` lambdas over `ARRAY_AGG` in a grouped query; column expression ranges in compiled SQL that SQL and Python macros, a variable and cursor bounds rewrote, and columns qualified by their reference call, whose ranges are dropped | +| Lineage and analysis | clauses whose columns decide rows without being output (`WHERE`, `QUALIFY`, `GROUP BY` by position and `ALL`, `ORDER BY` under `LIMIT`, `EXISTS`, a `FLATTEN` input, `ROLLUP` by position, `EXCEPT` under `LIMIT`); `RIGHT JOIN ... USING`, `NATURAL JOIN`, a `USING` key under a later outer join, and unmatched `ASOF JOIN` rows; `CONNECT BY` beside a column named `level`; a recursive CTE without `RECURSIVE` whose columns shift per iteration; `LAST_DAY` with a date part; positional columns and the names Snowflake gives unaliased expressions; `TEXT(5)` and widened `COUNT` contracts; `LAG` and `LEAD` with one, two and three arguments; a comma-joined `LATERAL` whose nested derived table reads the left item; relations aliased `first` and `last`, one without `AS`, the words of Snowflake's read-order clauses; untyped and typed `FILTER` lambdas over `ARRAY_AGG` in a grouped query; column expression ranges in compiled SQL that SQL and Python macros, a variable and cursor bounds rewrote, and columns qualified by their reference call, whose ranges are dropped | | Python functions | volatile tokens and numbers from a column, a constant and no argument, and `DIV0` of a volatile call beside look-alike names, checked by assertions that hold for any values; a handler answering NULL input without `STRICT`; Python `None` as JSON null, and datetimes, Decimals and integers past 2^53 handed to `VARIANT` and `FLOAT` results | | Scenarios and lifecycle | typed values across model boundaries; `VARIANT` expected output; a star under a lower-case contract and a quoted camelCase export; a snapshot keyed and compared on quoted camelCase columns; a cursor-window incremental model over far-apart fixture loads; a change log merged across two loads, checked against a full rebuild | | Translation refusals | one model per construct that translation tools refuse or guard, most putting a construct refused only under strict checking before one refused by default, so a model shows both: `FLOAT` values through sums, averages, running totals, arrays, objects, `HASH`, `TO_CHAR` and `::NUMBER(38, 10)`; `VARIANT` dates, decimals and XML; `ARRAY_AGG` without `WITHIN GROUP`, sparse arrays and `ARRAY(NUMBER)` casts; `REDUCE`, `FILTER` and `TRANSFORM` lambdas; patterns and `REGEXP_REPLACE` replacements built from columns, and lazy patterns; `TRY_TO_DATE` with a format from a column; zoned literals, `CONVERT_TIMEZONE` from `CURRENT_TIMESTAMP`, `SEQ8`, `GENERATOR` with an expression `ROWCOUNT`; `PIVOT`, `ANY_VALUE`, `IGNORE NULLS` around `IFF`, unaliased columns read by Snowflake's name, `UNION` branches whose column is always NULL; `TO_NUMBER`, `TO_DECIMAL` and `TRY_BASE64_DECODE_BINARY`; an open (uncontracted) source `edge__supplier_notes`, the table function, read for one basket and after `LATERAL` for every basket, and the hook-created function. `rpt_edge_case_model_keys` and `rpt_edge_case_array_model_keys` read every model in the group, so a refusal there also refuses a downstream model | diff --git a/benchmarks/duckshop/project/models/intermediate/edge_cases/int_edge_first_last_aliases.sql b/benchmarks/duckshop/project/models/intermediate/edge_cases/int_edge_first_last_aliases.sql new file mode 100644 index 0000000000..63fbd3340b --- /dev/null +++ b/benchmarks/duckshop/project/models/intermediate/edge_cases/int_edge_first_last_aliases.sql @@ -0,0 +1,42 @@ +MODEL ( + description """ + One row per amount check with its group name read through relations aliased first and last, the + words of Snowflake's read-order clauses: each alias names its relation, so neither join is + unused, and a condition on the last relation decides which of its rows match + """, + tags [edge_case], + columns ( + check_id (type VARCHAR, nullable false, audits [not_null, unique]), + first_group_name (type VARCHAR), + last_group_name (type VARCHAR), + ), +); + +WITH checks AS ( + SELECT + c.check_id, + c.group_code + FROM __ref("stg_edge_amount_checks") AS c +), + +group_names AS ( + SELECT + v.group_code, + v.group_name + FROM VALUES ('G-1', 'Mallard desk'), ('G-2', 'Teal desk') AS v(group_code, group_name) +), + +final AS ( + SELECT + c.check_id::VARCHAR AS check_id, + first.group_name::VARCHAR AS first_group_name, + last.group_name::VARCHAR AS last_group_name + FROM checks AS c + LEFT JOIN group_names AS first ON c.group_code = first.group_code + LEFT JOIN group_names last + ON c.group_code = last.group_code + AND last.group_name <> 'Teal desk' +) + +SELECT * +FROM final diff --git a/benchmarks/duckshop/project/tests/unit/intermediate/edge_cases/test_int_edge_first_last_aliases.sql b/benchmarks/duckshop/project/tests/unit/intermediate/edge_cases/test_int_edge_first_last_aliases.sql new file mode 100644 index 0000000000..9b900f43ea --- /dev/null +++ b/benchmarks/duckshop/project/tests/unit/intermediate/edge_cases/test_int_edge_first_last_aliases.sql @@ -0,0 +1,53 @@ +TEST (name "int_edge_first_last_aliases__reads_each_group_name_through_its_aliased_relation"); + +WITH __ref__stg_edge_amount_checks AS ( + SELECT + v.check_id, + v.group_code, + v.narrow_key::NUMBER(18, 0) AS narrow_key, + v.wide_key::NUMBER(38, 0) AS wide_key, + v.key_text, + v.amount::NUMBER(18, 2) AS amount, + v.fine_amount::NUMBER(20, 15) AS fine_amount, + v.ratio::FLOAT AS ratio, + v.json_text + FROM VALUES + ('AC-01', 'G-1', 7, '7', '01', 10.00, 0.123456789012345, 0.29, NULL), + ('AC-02', 'G-1', 12, '12345678901234567890123', '1', -0.50, 0.123456789012344, 1.005, NULL), + ('AC-03', 'G-1', NULL, '12', '12', 2.50, 0.5, 2.675, NULL), + ('AC-04', 'G-2', 123456789012345678, '123456789012345678', ' 7', 0.00, 1, -155.5, NULL), + ('AC-05', 'G-2', 99, NULL, NULL, NULL, NULL, NULL, NULL), + ('AC-06', 'G-3', 5, '5', 'n/a', 999999999999.99, 0.000000000000001, 0.57, NULL) AS v(check_id, group_code, narrow_key, wide_key, key_text, amount, fine_amount, ratio, json_text) +), + +__expected__int_edge_first_last_aliases AS ( + SELECT + 'AC-01' AS check_id, + 'Mallard desk' AS first_group_name, + 'Mallard desk' AS last_group_name + UNION ALL + SELECT + 'AC-02' AS check_id, + 'Mallard desk' AS first_group_name, + 'Mallard desk' AS last_group_name + UNION ALL + SELECT + 'AC-03' AS check_id, + 'Mallard desk' AS first_group_name, + 'Mallard desk' AS last_group_name + UNION ALL + SELECT + 'AC-04' AS check_id, + 'Teal desk' AS first_group_name, + CAST(NULL AS VARCHAR) AS last_group_name + UNION ALL + SELECT + 'AC-05' AS check_id, + 'Teal desk' AS first_group_name, + CAST(NULL AS VARCHAR) AS last_group_name + UNION ALL + SELECT + 'AC-06' AS check_id, + CAST(NULL AS VARCHAR) AS first_group_name, + CAST(NULL AS VARCHAR) AS last_group_name +)