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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]