Skip to content

Snowflake: decode octal/hex/unicode string-literal escapes - #17

Merged
wojpadlo merged 2 commits into
mainfrom
lav-1329-escapes-on-main
Jul 30, 2026
Merged

Snowflake: decode octal/hex/unicode string-literal escapes#17
wojpadlo merged 2 commits into
mainfrom
lav-1329-escapes-on-main

Conversation

@wojpadlo

Copy link
Copy Markdown

Decodes Snowflake single-quoted string-literal escapes in the tokenizer:

  • \ooo (octal), \xhh (hex) and \uhhhh (unicode) → the corresponding code point
  • \0 stays NUL
  • unrecognized letters (\a, \Z, …) collapse to the bare letter
  • malformed \x / \u raise a tokenizer error

Gated behind a new supports_snowflake_string_literal_escapes dialect capability so other backslash-escaping dialects keep their MySQL/BigQuery semantics.

Files: src/tokenizer.rs, src/dialect/mod.rs, src/dialect/snowflake.rs, tests/sqlparser_common.rs.

Why

Parser-fork side of LAV-1329 ("string-literal escape parity"), and a prerequisite for LAV-1330 (multi-character FIELD_DELIMITER / RECORD_DELIMITER on the CSV load path), which needs a hex-escaped delimiter like FIELD_DELIMITER = '\x7C\x7C' to decode to ||. The currently pinned fork rev (b5e11f27) maps unknown escapes to the bare char (\x7Cx7C), so the emulator never sees ||; real Snowflake decodes it.

Note

This is the same single commit as #16, but rebased directly onto main instead of stacked on the lav-1362-masking-policy branch. The escape commit cherry-picks cleanly onto main (only tokenizer.rs + dialect/* + one test), decoupling it from the red feature-branch stack so it can merge and be consumed independently. Superseding #16.

🤖 Generated with Claude Code

wojpadlo and others added 2 commits July 30, 2026 13:06
Decode \ooo, \xhh and \uhhhh as Unicode code points, keep \0 as NUL,
collapse unrecognized letters (\a, \Z) to the bare letter, and raise a
tokenizer error on malformed \x / \u — gated behind a new
supports_snowflake_string_literal_escapes dialect capability so other
backslash-escaping dialects keep MySQL/BigQuery semantics.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…less_return_with_question_mark)

Pre-existing lints in ast/parser/tests/examples surfaced by the stable
toolchain advancing to rust-1.97 (main last passed CI on the older
stable). Mechanical fixes only; no behaviour change. Unrelated to the
escape-parity commit but required to get this PR's lint job green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@wojpadlo
wojpadlo force-pushed the lav-1329-escapes-on-main branch from d5f5542 to dba3a43 Compare July 30, 2026 11:07
@wojpadlo
wojpadlo merged commit 9f68fe9 into main Jul 30, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant