You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/09/24 20:21:24 UTC

(datafusion-sqlparser-rs) branch gh-readonly-queue/main/pr-2518-0fd4fa892c91e2f5ee6ffc0bcf614219a921b5e3 created (now 220e50a05)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-2518-0fd4fa892c91e2f5ee6ffc0bcf614219a921b5e3
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git


      at 220e50a05 Snowflake: parse nested COPY transformation paths (#2518)

This branch includes the following new commits:

     new 220e50a05 Snowflake: parse nested COPY transformation paths (#2518)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


(datafusion-sqlparser-rs) 01/01: Snowflake: parse nested COPY transformation paths (#2518)

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-2518-0fd4fa892c91e2f5ee6ffc0bcf614219a921b5e3
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git

commit 220e50a053b7ae225a9c08c246a3bbc1c4a1616c
Author: Artem Osipov <59...@users.noreply.github.com>
AuthorDate: Thu Sep 24 20:21:00 2026 +0000

    Snowflake: parse nested COPY transformation paths (#2518)
---
 src/dialect/snowflake.rs     | 12 ++++++++----
 tests/sqlparser_snowflake.rs | 17 +++++++++++++++++
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/dialect/snowflake.rs b/src/dialect/snowflake.rs
index eff1e2f31..97f7cd2ef 100644
--- a/src/dialect/snowflake.rs
+++ b/src/dialect/snowflake.rs
@@ -1619,10 +1619,14 @@ fn parse_select_item_for_data_load(
         }
     }
 
-    // A trailing `::` means this is a cast expression (e.g.
-    // `$1:"col"::NUMBER(38,0)`), not a stage-load-select-item.
-    if matches!(parser.peek_token_ref().token, Token::DoubleColon) {
-        return parser.expected("stage load select item", parser.peek_token());
+    // More complex paths and casts must fall back to the standard expression
+    // parser so it can preserve the complete JsonAccess / Cast expression.
+    if matches!(
+        parser.peek_token_ref().token,
+        Token::Colon | Token::Period | Token::LBracket | Token::DoubleColon
+    ) {
+        let token = parser.next_token();
+        return parser.expected("end of simple staged field", token);
     }
 
     // as
diff --git a/tests/sqlparser_snowflake.rs b/tests/sqlparser_snowflake.rs
index ab6e24254..0d3edaad8 100644
--- a/tests/sqlparser_snowflake.rs
+++ b/tests/sqlparser_snowflake.rs
@@ -2596,6 +2596,23 @@ fn test_copy_into_with_cast_transformation() {
             "COPY INTO my_company.emp_basic (a, b) FROM ",
             r#"(SELECT t.$1:plain AS plain, $1:"B"::TEXT FROM @stg AS t)"#,
         ),
+        // https://docs.snowflake.com/en/user-guide/tutorials/script-data-load-transform-parquet
+        concat!(
+            "COPY INTO my_company.emp_basic (a, b) FROM ",
+            "(SELECT $1:continent::VARCHAR, $1:country:name::VARCHAR FROM @stg)",
+        ),
+        concat!(
+            "COPY INTO my_company.emp_basic (a) FROM ",
+            "(SELECT $1:country.name::VARCHAR FROM @stg)",
+        ),
+        concat!(
+            "COPY INTO my_company.emp_basic (a) FROM ",
+            "(SELECT $1['country']['name']::VARCHAR FROM @stg)",
+        ),
+        concat!(
+            "COPY INTO my_company.emp_basic (a) FROM ",
+            "(SELECT t.$1:country.name::VARCHAR AS country FROM @stg AS t)",
+        ),
     ];
     for sql in variants {
         snowflake().verified_stmt(sql);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org