You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Heredoc string literals ($tag$ … $tag$) are lexed as identifiers #346
ClickHouse reads $tag$…$tag$ as a heredoc string literal. The parser lexes these tokens as unquoted identifiers, and Format re-emits them bare. As a result, the AST and the formatted SQL disagree with what ClickHouse executes: ClickHouse reads everything between two $x$ tokens as one string.
The cause is #147 (the fix for #144, service$$name), which added $ to IsIdentPart. Since then an unquoted identifier runs on through every $.
Reproduction (v0.5.7)
stmts, _:=parser.NewParser("SELECT $x$ AS a FROM t WHERE b = $x$").ParseStmts()
fmt.Println(parser.Format(stmts[0]))
// SELECT $x$ AS a FROM t WHERE b = $x$ (both $x$ tokens are *parser.Ident)
Query
Parser
ClickHouse 24.6 / 25.6 / 26.6
SELECT $tag$hello$tag$
identifier $tag$hello$tag$
string 'hello'
SELECT $x$ AS a FROM t WHERE b = $x$
identifiers $x$, a, t, b, $x$
string ' AS a FROM t WHERE b = '
On 26.x the tag must match [A-Za-z0-9_]*. Before 26.x it can contain any characters up to the next $.
Expected behaviour
Lex $tag$…$tag$ as a string literal and format it so it round-trips. A $ inside or at the end of a bare word (service$$name, a$b) should stay valid, as #144 requires.
Activity
git-hulk commentedon Nov 20, 2026
@thiemok Thanks for your report, it has been resolved in #347.