iffyio commented on code in PR #1702:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1702#discussion_r1943620318
##########
src/dialect/snowflake.rs:
##########
@@ -182,6 +183,15 @@ impl Dialect for SnowflakeDialect {
return Some(parse_file_staging_command(kw, parser));
}
+ if parser.parse_keyword(Keyword::SHOW) {
+ let terse = parser.parse_keyword(Keyword::TERSE);
+ if parser.parse_keyword(Keyword::OBJECTS) {
+ return Some(parse_show_objects(terse, parser));
+ } else {
+ return Some(parser.parse_show());
Review Comment:
what would be the behavior if `terse` is true here, can we maybe include a
test case demonstrating that scenario?
##########
src/parser/mod.rs:
##########
@@ -14172,7 +14172,7 @@ impl<'a> Parser<'a> {
false
}
- fn parse_show_stmt_options(&mut self) -> Result<ShowStatementOptions,
ParserError> {
+ pub fn parse_show_stmt_options(&mut self) -> Result<ShowStatementOptions,
ParserError> {
Review Comment:
```suggestion
pub(crate) fn parse_show_stmt_options(&mut self) ->
Result<ShowStatementOptions, ParserError> {
```
##########
src/ast/mod.rs:
##########
@@ -2980,6 +2980,32 @@ pub enum Statement {
show_options: ShowStatementOptions,
},
/// ```sql
+ /// SHOW [ TERSE ] OBJECTS [ LIKE '<pattern>' ]
+ /// [ IN
+ /// {
+ /// ACCOUNT
|
+ ///
+ /// DATABASE
|
+ /// DATABASE <database_name>
|
+ ///
+ /// SCHEMA
|
+ /// SCHEMA <schema_name>
|
+ /// <schema_name>
+ ///
+ /// APPLICATION <application_name>
|
+ /// APPLICATION PACKAGE
<application_package_name> |
+ /// }
+ /// ]
+ /// [ STARTS WITH '<name_string>' ]
+ /// [ LIMIT <rows> [ FROM '<name_string>' ] ]
+ /// ```
Review Comment:
Thinking since this is quite verbose we can either leave it out, relying on
the link to the documentation and a description or we can use a shorter summary
of the syntax like an example sql statement?
##########
tests/sqlparser_snowflake.rs:
##########
@@ -2975,6 +2975,25 @@ fn test_parse_show_schemas() {
snowflake().verified_stmt("SHOW SCHEMAS IN DATABASE STARTS WITH 'abc'
LIMIT 20 FROM 'xyz'");
}
+#[test]
+fn test_parse_show_objects() {
+ snowflake().verified_stmt("SHOW OBJECTS");
Review Comment:
Since this introduces a new node in the AST, can we add an assertion for one
of these test cases covering that the AST looks like what is expected? i.e a
test in [this
syle](https://github.com/apache/datafusion-sqlparser-rs/blob/e13a1b844b176746dbc5f04987e0b97d78df88b4/tests/sqlparser_snowflake.rs#L51-L59)
##########
src/ast/mod.rs:
##########
@@ -2980,6 +2980,32 @@ pub enum Statement {
show_options: ShowStatementOptions,
},
/// ```sql
+ /// SHOW [ TERSE ] OBJECTS [ LIKE '<pattern>' ]
+ /// [ IN
+ /// {
+ /// ACCOUNT
|
+ ///
+ /// DATABASE
|
+ /// DATABASE <database_name>
|
+ ///
+ /// SCHEMA
|
+ /// SCHEMA <schema_name>
|
+ /// <schema_name>
+ ///
+ /// APPLICATION <application_name>
|
+ /// APPLICATION PACKAGE
<application_package_name> |
+ /// }
+ /// ]
+ /// [ STARTS WITH '<name_string>' ]
+ /// [ LIMIT <rows> [ FROM '<name_string>' ] ]
+ /// ```
+ /// Snowflake-specific statement
+ /// <https://docs.snowflake.com/en/sql-reference/sql/show-objects>
+ ShowObjects {
+ terse: bool,
+ show_options: ShowStatementOptions,
Review Comment:
Could we use a struct to wrap the arguments? we're currently trying to move
away from the anonymous struct pattern
(https://github.com/apache/datafusion-sqlparser-rs/issues/1204)
Something like
```rust
struct ShowObjects {
terse: bool,
show_options: ShowStatementOptions,
}
Statement::ShowObjects(ShowObjects)
```
--
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]