Repository navigation
Let comments never change whether a statement converts (D327) - #134
Merged
Merged
Conversation
A comment straight after SELECT set post_select_comments, which no rule read, so the whole statement refused (602 of the playground's 3,263 generated statements). It is now cosmetic like every other comment field. A comment after an expression wrapped it in an annotated node, so a rule needing a literal, such as ROUND's scale, saw a wrapper and refused; a wrapper that holds only comments is now unwrapped. Both are dropped from the output, as comments elsewhere are.
kvlonge
added a commit
that referenced
this pull request
Nov 6, 2026
Unwrapping comment-only wrappers dropped the comment from an unaliased literal's written text, so SELECT 'x' /* c */ took the name 'X', which no receipt records. Main had the same gap. The select item's own wrapper now stays, and the projection rule refuses it with SQ0009 unless it wraps a column, star or alias, as the column-name rule's conditions state.
kvlonge
added a commit
that referenced
this pull request
Nov 6, 2026
No behaviour change: the select-item wrapper rule from the previous commit now lives in unwrap_field, and the inline comment and long doc comment go.
Contributor
Author
|
D94 gate on exact head 9c008e0 (58731ec + merge of main fc15d51, clean, no conflicts), every .rs touched before the build:
|
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.
Launch blocker D327 (from D320): comments must never change whether a statement converts.
The bug
SELECT /* c */ 1 AS vandSELECT -- note\n 1 AS vrefused the whole statement with SQ0002, "no rule handlespost_select_commentsset on node:select". That was 602 of the playground lane's 3,263 generated statements. Snowflake compiles both and returns column V (A's receipts,wip/d320-playground-basics6111431), so the refusal was ours alone.The fix
Both changes are in
conversion/_helpers/support/tree.rs, which already decides which tree fields are cosmetic:post_select_commentsjoinsCOSMETIC_FIELDS, besidetrailing_comments,pre_alias_commentsand the others. The comment is dropped from the output, the same as comments everywhere else.The sweep turned up a second case. A comment straight after an expression wraps it in an
annotatednode that holds onlythisandtrailing_comments. A rule that needs a literal then sees the wrapper:ROUND(amount, 1 /* c */)refused with SQ0003 whileROUND(amount, 1)converted. When the tree is built, a wrapper that holds nothing but comments is now replaced by the node it wraps.Round 1 review (auditor record 09453d8) found that unwrapping also renamed unaliased items:
SELECT 'x' /* c */ FROM orderstook the name'X'. Main had the same gap, since it named it'X'too; no receipt records whether Snowflake's name includes the comment. A select item's own wrapper now stays (unwrap_field), and the projection rule refuses it with SQ0009 unless it wraps a column, star or alias, as the column-name rule's conditions already state.SELECT 'x' /* c */ AS vandSELECT amount /* c */still convert.Sweep
38 comment positions were converted over a schema (orders, customers). With only change 1, 1 of the first 32 still refused (the comment after ROUND's literal scale); with both changes, 0 of 38 refuse. I didn't run the sweep on unchanged main; the after-SELECT positions are the D320 report's. The positions:
Tests
test_analyzegains five rows: a block and a line comment after SELECT, comments after SELECT in a CTE and a subquery, a comment after a literal argument, and an unaliased literal carrying a comment (SQ0009, which fails with query.rs reverted to main). Withtree.rsreverted to main, the first new row fails; with the fix, all pass.Gate
D94 gate on exact head 9c008e0 (58731ec + merge of main fc15d51, clean, no conflicts), every .rs touched before the build:
make check-merge(check-ci + test-rust): exit 0. fmt, clippy, ruff, ty and fensu clean; 24/24 test binaries passed.sqlquack verify --require-verified --strict-errors --python .venv/bin/python: 12,033 cases, 7,997 passed, 1,035 diverged as expected, 2,964 refused, 37 typed, 0 pending, 0 unproven, 0 failed; 226 of 226 equivalences and rules verified.syntax-coverage results … --againstmain fc15d51's results-baseline.json: 0 regressions, 0 other changes; no baseline re-record needed.Auditor: approved at 7392627 (record 6a306de), extended to 58731ec (record 976fb43). GitHub Actions is blocked by billing; the local D94 gate counts.