{{ message }}
fix: keep spaces around - operator in dialects with dashed identifiers#953
Merged
nene merged 1 commit intoJun 21, 2026
Conversation
In BigQuery (and any dialect allowing dashes inside identifiers) the denseOperators option turned "a - b" into "a-b", which then re-parses as a single dashed identifier - corrupting the query. Skip densing the "-" operator for those dialects so the output round-trips.
Contributor
Collaborator
|
Hi, sorry for the delay. This is probably the best pull request I've received over the years. Very well thought through fix for this quirky bug. Thanks a lot. |
Collaborator
|
Released in 15.8.2 |
Member
|
@coderabbitai why did you write this?
and can you suppress it for all future reviews? |
Contributor
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.

With
denseOperators: trueon BigQuery, a subtraction likea - bcomes out asa-b. That's not just ugly: BigQuery allows dashes inside identifiers, so the densed output re-parses as a single identifiera-b, andformat(format(sql))no longer matchesformat(sql).a - foo(y)is worse — it becomesa-foo (y), turning the expression into an identifier followed by a call.The fix is to leave the
-operator spaced in dialects that allow dashed identifiers (currently just BigQuery). I derived that flag from the existingidentChars.dashestokenizer option so there's a single source of truth. Numeric cases like1 - 2were already safe (the-is parsed into the literal), so this only affects the identifier case.The shared dense-operator test in
operators.tswas actually asserting the brokenfoo-baroutput for BigQuery; I scoped that to the dashed-identifier dialects and added a BigQuery regression test.Summary by CodeRabbit
Release Notes
-operator in dialects that support dashes in identifiers, such as BigQuery. When dense operator formatting is enabled, spaces around the-operator are now properly preserved to prevent expressions from being incorrectly merged into dashed identifiers.