Repository navigation
Parse ClickHouse heredocs as string literals - #347
Merged
Merged
Conversation
The lexer treated a leading `$` as the start of an identifier, so the AST could describe clauses that ClickHouse reads as string content. For `SELECT $x$ AS a FROM t WHERE b = $x$`, the parser reported a table and a filter. ClickHouse returns the single string `' AS a FROM t WHERE b = '`. Recognize matching heredoc delimiters using the ClickHouse 26.x tag rules. Format the body as a single-quoted literal, escaping quotes and backslashes to preserve its value. Identifiers such as `service$$name` and `a$b` still parse as before. The new AST and formatting fixtures cover both reported queries. Fixes AfterShip#346 Assistant-By gpt-6.2-astra
Keep the original delimiter and raw body in the AST so both compact and beautified SQL retain the heredoc spelling. Write multiline bodies verbatim because indentation becomes part of the string value.
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.
The lexer treated a leading
$as the start of an identifier, so theAST could describe clauses that ClickHouse reads as string content.
For
SELECT $x$ AS a FROM t WHERE b = $x$, the parser reported a tableand a filter. ClickHouse returns a single string containing the text
between the two
$x$delimiters.Recognize matching heredoc delimiters using the ClickHouse 26.x tag
rules. Keep the original delimiter and raw body in the AST so both
compact and beautified SQL preserve the heredoc spelling, including
whitespace inside multiline strings. Identifiers such as
service$$nameand
a$bstill parse as before.Fixes #346
Assistant-By gpt-6.2-astra