Repository navigation
fix: lay out Snowflake expression macro bodies instead of dedenting them - #1494
Merged
Merged
Conversation
On Snowflake, `sqb format` removed one indentation level from an expression macro or scalar function body on every run, so `--check` never settled. The body was formatted as an unaliased SELECT item, which the Snowflake formatter keeps exactly as written, and the dedent that removes the SELECT again then stripped an authored level from every line. Expression bodies are now formatted as an aliased item, which every dialect lays out, and the alias is removed again; a result without it is a fault that leaves the file unchanged. The dedent also leaves lines inside a $$ dollar-quoted string alone instead of changing the string. DuckShop gains a scoped Snowflake expression macro whose body holds a comment.
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
On Snowflake,
sqb formatdidn't lay out an expression-macro body. Each run removed one indentation level until the body was flush left, sosqb format --checknever settled. The same body formats properly and stays stable on DuckDB. Scalar SQL function bodies take the same path.SQLBuild formats an expression body as a one-item
SELECTand dedents the result. The Snowflake formatter keeps unaliased select items exactly as written, because Snowflake names such a column by its text. So only the first line moved, and the dedent then stripped one authored level from every other line.Changes
;stays out of the formatted SQL.$$dollar-quoted string alone. Before, it changed the contents of a multi-line$$string, on every dialect.stg_edge_ticket_notes. Compiled results are unchanged.Verification
--checkpasses, a second run changes nothing, and the project compiles. Fails on the released extension.cargo test -p sqlbuild-rules, the format-preservation tests,fensu checkand clippy pass.