Skip to content

fix(snowflake): handle DollarString in PUT/FROM and UUID paths in stage references#191

Merged
tobilg merged 1 commit into
tobilg:mainfrom
mesmacosta:fix/snowflake-jdbc-parse-failures
Apr 28, 2026
Merged

fix(snowflake): handle DollarString in PUT/FROM and UUID paths in stage references#191
tobilg merged 1 commit into
tobilg:mainfrom
mesmacosta:fix/snowflake-jdbc-parse-failures

Conversation

@mesmacosta
Copy link
Copy Markdown
Contributor

@mesmacosta mesmacosta commented Apr 27, 2026

Summary

Fixes 10 SQL parse failures from the Snowflake JDBC driver (v4.0.2) test suite by adding support for dollar-quoted strings in PUT/FROM statements and UUID-style path segments in stage references.

Changes

1. DollarString support in PUT statements

The JDBC driver wraps stage references with special characters in $$...$$ (dollar-quoted strings):

put file:///tmp/placeholder $$@%"ice cream (nice)"$$ overwrite=true

Fix:

  • PUT source path loop now stops at DollarString token boundary
  • PUT target parser accepts DollarString as a valid stage reference (alongside String and Parameter)

2. DollarString support in FROM clause

The JDBC driver uses dollar-quoted stage paths in SELECT FROM:

SELECT $1 FROM $$@%"ice cream (nice)"/$$

Fix: The FROM-clause table parser now accepts DollarString as a valid table source, similar to how it already accepts String for DuckDB.

3. UUID-style path segments in stage references

JDBC-generated PUT statements use UUID-based paths for upload operations:

-- User stage with UUID path
PUT file:///tmp/f @~/00626646-bb1e-4729-a1ab-d4b96aebbed5/testUploadStream overwrite=true

-- Named stage with UUID subpath
PUT file:///tmp/f.csv @teststage/c8b31cea-a6d1-4413-936d-bf8c9d63ab9f AUTO_COMPRESS=FALSE

Root cause: UUIDs tokenize as Number + Dash + Identifier + Dash etc. The path consumption loops in parse_stage_reference_as_string only accepted Var, keywords, and identifiers.

Fix:

  • Added Number and Dash to accepted token types in all 3 path-segment loops (user stage @~, named stage @name, and Var-style @var)
  • Changed path segment consumption from single-token (if) to multi-token (while) loops to handle composite UUID segments like c8b31cea-a6d1-4413

Test Results

  • 33/33 regression tests pass (8 new + 25 existing)
  • 997/997 main test suite tests pass (0 regressions)

Errors Resolved

Error ID SQL Pattern Root Cause
[6737] PUT ... $$@%"ice cream"$$ ... DollarString not accepted as PUT target
[6740] SELECT $1 FROM $$@%"..."$$ DollarString not accepted in FROM
[7635] PUT ... @~/UUID/testUpload ... UUID path segments in @~
[7650] PUT ... @~/UUID/testCompress ... UUID path segments in @~
[14457] PUT ... @~/UUID/testUpload ... UUID path segments in @~
[6769] PUT ... @stage/UUID AUTO_COMPRESS=FALSE UUID subpath in named stage
[6772] PUT ... @stage/UUID AUTO_COMPRESS=FALSE UUID subpath in named stage
[6775] PUT ... @stage/UUID AUTO_COMPRESS=TRUE UUID subpath in named stage
[6778] PUT ... @stage/UUID AUTO_COMPRESS=TRUE UUID subpath in named stage

Related

…ge references

- Accept DollarString (79193...79193) as PUT target stage reference
- Stop PUT source path consumption at DollarString boundary
- Accept DollarString as table source in SELECT FROM (Snowflake stage paths)
- Allow Number and Dash tokens in stage path segments for UUID-style paths
  (@~/uuid-xxx/name, @stage/uuid-xxx)
- Change path segment consumption from single-token (if) to multi-token
  (while) loops to handle composite paths like c8b31cea-a6d1-4413

Fixes JDBC-generated SQL patterns:
  PUT file:///tmp/f $$@%"ice cream"$$ overwrite=true
  SELECT $1 FROM $$@%"ice cream"/$$
  PUT file:///tmp/f @~/00626646-bb1e-4729-a1ab-d4b96/testUpload overwrite=true
  PUT file:///tmp/f.csv @stage/c8b31cea-a6d1-4413 AUTO_COMPRESS=FALSE

Related: tobilg#164, tobilg#165
@tobilg tobilg merged commit 1361438 into tobilg:main Apr 28, 2026
14 of 15 checks passed
tobilg added a commit that referenced this pull request Apr 28, 2026
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.

Unable to parse a few queries from Java snowflake-jdbc tests

2 participants