Repository navigation
fix: end Databricks raw string literals at the first quote - #2938
Merged
manticore-projects merged 1 commit intoNov 18, 2026
Merged
manticore-projects merged 1 commit into
manticore-projects merged 1 commit into
Conversation
Contributor
|
Thank you! |
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.
Under
Dialect.DATABRICKStheS_CHAR_LITERALtoken action lets a backslash escape the closing quote of a raw literalr'...', because the dialect enablesallowBackslashEscapeCharacter, andr"..."is not lexed as a literal at all but as the identifierrfollowed by a backslash-escaped double-quoted string. Spark's lexer ends a raw literal at the first quote ('R\'' (~'\'')* '\''and'R"' (~'"')* '"'inSqlBaseLexer.g4), so a trailing backslash is plain text. As a resultCCJSqlParserUtil.parse("SELECT r'a\' UNION SELECT pw FROM secrets -- '", p -> p.withDialect(Dialect.DATABRICKS))returns one string literal andTablesNamesFinderfinds no table, while Databricks runs theUNIONand readssecrets;r"a\" UNION SELECT pw FROM secrets -- "behaves the same way. A table allowlist orFeaturesAllowedcheck run with this dialect therefore validates a different statement from the one the server executes. I found it while comparing the raw-string rules of the dialects that enable backslash escapes. UnderDATABRICKSthe token now endsR'...'at the first quote and lexesR"..."as a raw literal (StringValuekeeps theRprefix and the double quote); other dialects splitR"back into the identifier and the quoted name as before, and BigQuery raw strings are left as they are. NewStringValueTestcases fail before and pass after; spotless, checkstyle, PMD, SpotBugs, the grammar ambiguity check and the test suite pass, except for 35 tests that fail on my Windows machine for environmental reasons (Mockito cannot load its MockMaker, andParserKeywordsUtilsTestcannot create its temp file).