You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "romanoff (via GitHub)" <gi...@apache.org> on 2026/01/16 23:18:36 UTC

[PR] Fixed select dollar column from stage for snowflake [datafusion-sqlparser-rs]

romanoff opened a new pull request, #2165:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2165

   Fixed this query for snowflake:
   ```sql
   SELECT t.$1, t.$2 FROM @mystage1(file_format => 'myformat', pattern => '.*data.*[.]csv.gz') t
   ```
   Documentation:
   https://docs.snowflake.com/en/user-guide/querying-stage?referrer=grok.com#example-1-querying-columns-in-a-csv-file
   
   Specifically `t.$1` part didn't work before


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Fixed select dollar column from stage for snowflake [datafusion-sqlparser-rs]

Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio commented on code in PR #2165:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2165#discussion_r2741798777


##########
src/parser/mod.rs:
##########
@@ -15199,6 +15216,35 @@ impl<'a> Parser<'a> {
         }
     }
 
+    /// Parse a Snowflake stage reference as a table factor.
+    /// Handles syntax like: `@mystage1 (file_format => 'myformat', pattern => '...')`
+    fn parse_snowflake_stage_table_factor(&mut self) -> Result<TableFactor, ParserError> {
+        // Parse the stage name starting with @
+        let name = crate::dialect::parse_snowflake_stage_name(self)?;
+
+        // Parse optional stage options like (file_format => 'myformat', pattern => '...')
+        let args = if self.consume_token(&Token::LParen) {
+            Some(self.parse_table_function_args()?)
+        } else {
+            None

Review Comment:
   can we add a test case that doesn't include table function args?



##########
src/parser/mod.rs:
##########
@@ -15199,6 +15216,35 @@ impl<'a> Parser<'a> {
         }
     }
 
+    /// Parse a Snowflake stage reference as a table factor.
+    /// Handles syntax like: `@mystage1 (file_format => 'myformat', pattern => '...')`
+    fn parse_snowflake_stage_table_factor(&mut self) -> Result<TableFactor, ParserError> {
+        // Parse the stage name starting with @
+        let name = crate::dialect::parse_snowflake_stage_name(self)?;
+
+        // Parse optional stage options like (file_format => 'myformat', pattern => '...')
+        let args = if self.consume_token(&Token::LParen) {
+            Some(self.parse_table_function_args()?)
+        } else {
+            None
+        };
+
+        let alias = self.maybe_parse_table_alias()?;

Review Comment:
   can we add a test case that doesn't include an alias?



##########
src/parser/mod.rs:
##########
@@ -15103,6 +15115,11 @@ impl<'a> Parser<'a> {
             && self.peek_keyword_with_tokens(Keyword::SEMANTIC_VIEW, &[Token::LParen])
         {
             self.parse_semantic_view_table_factor()
+        } else if dialect_of!(self is SnowflakeDialect)

Review Comment:
   If we need a guard for this I think we would instead use a method on the dialect trait (we're moving away from the dialect_of macro for new code). But I think the guard shouldn't be needed in the first place? so that if we see a `SELECT * FROM @foo T` we can always accept it regardless of dialect?



##########
src/parser/mod.rs:
##########
@@ -15199,6 +15216,35 @@ impl<'a> Parser<'a> {
         }
     }
 
+    /// Parse a Snowflake stage reference as a table factor.
+    /// Handles syntax like: `@mystage1 (file_format => 'myformat', pattern => '...')`

Review Comment:
   Can we link to the documentation that supports this syntax?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Fixed select dollar column from stage for snowflake [datafusion-sqlparser-rs]

Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio merged PR #2165:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2165


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Fixed select dollar column from stage for snowflake [datafusion-sqlparser-rs]

Posted by "romanoff (via GitHub)" <gi...@apache.org>.
romanoff commented on PR #2165:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2165#issuecomment-3899995060

   @iffyio Thank you. Updated


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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