Repository navigation
feat: name unaliased select items the way Snowflake does - #99
Merged
Merged
Conversation
SELECT COUNT(*) FROM orders is refused as SQ0009 because no recorded result shows the name Snowflake gives the column. These cases record those names for aggregates, literals and expressions as written.
Snowflake results for the five cases in cases/relational/unaliased_output_names.toml at 37346da.
An unaliased select item that is not a column takes its source text upper-cased as written, with spacing, line breaks and quotes kept, as the recorded receipts show. Literals, which carry no source position, are rebuilt from their value. Text outside ASCII or holding a comment is still refused with SQ0009.
Snowflake describes an untyped NULL result column as VARCHAR(0), as the recorded unaliased NULL literal shows; the converted statement now casts such a column to VARCHAR at its output, leaving inner queries untouched.
Naming an unaliased select item after its text now applies only to the shapes the receipts cover: literals in their recorded spellings, COUNT, SUM, MAX and AVG of a column or COUNT(*), LOWER, UPPER and COALESCE of columns and integers, a column then a literal under + - * / and ||, and a column cast to INTEGER, written with single spaces and at most one line break. Semi-structured paths and subscripts, which were named from a span stopping at their base, and every other shape refuse with SQ0009 again. A repeated result name now suggests aliasing each column.
kvlonge
added a commit
that referenced
this pull request
Nov 6, 2026
…s on main e9f002d Round 3 adds 76 queries: dbt_utils and dbt_date macros compiled by dbt-snowflake 1.12 (date_spine, get_date_dimension, pivot, generate_surrogate_key, deduplicate, cross-database macros, generic tests), dbt-snowflake's rendered snapshot SQL and incremental DML (merge with incremental predicates, delete+insert, insert_overwrite, snapshot merge), FLATTEN over VARIANT, and unaliased output names ahead of #99. Database and schema qualifiers are dropped; ORDERS_SNAPSHOT joins the model schema.
Contributor
Author
|
D94 gate on 1aba664 (main e9f002d merged in):
check-ci and test-rust ran on a3b4a52. 1aba664 changes only coverage/translation/results-baseline.json, and translation-results passes against it. |
kvlonge
added a commit
that referenced
this pull request
Nov 6, 2026
Contributor
Author
|
D94 gate for landing, after merging main c3555dd (#110):
|
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
Unaliased select items such as
SELECT COUNT(*) FROM ordersorSELECT 1were refused with SQ0009, the first thing many readers type. Snowflake names these columns after the item's text, and recorded receipts show exactly how for a set of shapes.Changes
1,-2,1.50,1e3, plain text, NULL, TRUE, FALSE); COUNT, SUM, MAX and AVG of a column, COUNT(*) and COUNT(DISTINCT col); LOWER, UPPER and COALESCE of columns and integers; a column then a literal under+ - * /and||; a column cast to INTEGER with CAST or::. Columns may be qualified, or quoted when already upper case. The text may hold single spaces, spaces inside parentheses and one line break.COUNT (*), other number spellings, and lower-case quoted identifiers. Each can be added with its own receipt.Verification