Skip to content

Commit f05eec9

Browse files
committed
Updates based on comments
1 parent 0d5c555 commit f05eec9

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/parser/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15447,10 +15447,8 @@ impl<'a> Parser<'a> {
1544715447
&& self.peek_keyword_with_tokens(Keyword::SEMANTIC_VIEW, &[Token::LParen])
1544815448
{
1544915449
self.parse_semantic_view_table_factor()
15450-
} else if dialect_of!(self is SnowflakeDialect)
15451-
&& self.peek_token_ref().token == Token::AtSign
15452-
{
15453-
// Snowflake stage reference: @mystage or @namespace.stage
15450+
} else if self.peek_token_ref().token == Token::AtSign {
15451+
// Stage reference: @mystage or @namespace.stage (e.g. Snowflake)
1545415452
self.parse_snowflake_stage_table_factor()
1545515453
} else {
1545615454
let name = self.parse_object_name(true)?;
@@ -15550,6 +15548,8 @@ impl<'a> Parser<'a> {
1555015548

1555115549
/// Parse a Snowflake stage reference as a table factor.
1555215550
/// Handles syntax like: `@mystage1 (file_format => 'myformat', pattern => '...')`
15551+
///
15552+
/// See: <https://docs.snowflake.com/en/user-guide/querying-stage>
1555315553
fn parse_snowflake_stage_table_factor(&mut self) -> Result<TableFactor, ParserError> {
1555415554
// Parse the stage name starting with @
1555515555
let name = crate::dialect::parse_snowflake_stage_name(self)?;

tests/sqlparser_snowflake.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4881,5 +4881,12 @@ fn test_truncate_table_if_exists() {
48814881

48824882
#[test]
48834883
fn test_select_dollar_column_from_stage() {
4884+
// With table function args and alias
48844885
snowflake().verified_stmt("SELECT t.$1, t.$2 FROM @mystage1(file_format => 'myformat', pattern => '.*data.*[.]csv.gz') t");
4886+
// Without table function args, with alias
4887+
snowflake().verified_stmt("SELECT t.$1, t.$2 FROM @mystage1 t");
4888+
// Without table function args, without alias
4889+
snowflake().verified_stmt("SELECT $1, $2 FROM @mystage1");
4890+
// With table function args, without alias
4891+
snowflake().verified_stmt("SELECT $1, $2 FROM @mystage1(file_format => 'myformat')");
48854892
}

0 commit comments

Comments
 (0)