This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 02d60cc0 Add support for USE SECONDARY ROLE (vs. ROLES) (#1637)
02d60cc0 is described below
commit 02d60cc0fc5bd9d5876214bc5a3d6a76343fac18
Author: Yoav Cohen <[email protected]>
AuthorDate: Sun Jan 5 19:30:06 2025 +0100
Add support for USE SECONDARY ROLE (vs. ROLES) (#1637)
---
src/parser/mod.rs | 2 +-
tests/sqlparser_snowflake.rs | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 47d4d6f0..0a245d8d 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -10529,7 +10529,7 @@ impl<'a> Parser<'a> {
}
fn parse_secondary_roles(&mut self) -> Result<Use, ParserError> {
- self.expect_keyword_is(Keyword::ROLES)?;
+ self.expect_one_of_keywords(&[Keyword::ROLES, Keyword::ROLE])?;
if self.parse_keyword(Keyword::NONE) {
Ok(Use::SecondaryRoles(SecondaryRoles::None))
} else if self.parse_keyword(Keyword::ALL) {
diff --git a/tests/sqlparser_snowflake.rs b/tests/sqlparser_snowflake.rs
index 9fe14783..b5add611 100644
--- a/tests/sqlparser_snowflake.rs
+++ b/tests/sqlparser_snowflake.rs
@@ -2782,6 +2782,14 @@ fn parse_use() {
snowflake().verified_stmt("USE SECONDARY ROLES ALL");
snowflake().verified_stmt("USE SECONDARY ROLES NONE");
snowflake().verified_stmt("USE SECONDARY ROLES r1, r2, r3");
+
+ // The following is not documented by Snowflake but still works:
+ snowflake().one_statement_parses_to("USE SECONDARY ROLE ALL", "USE
SECONDARY ROLES ALL");
+ snowflake().one_statement_parses_to("USE SECONDARY ROLE NONE", "USE
SECONDARY ROLES NONE");
+ snowflake().one_statement_parses_to(
+ "USE SECONDARY ROLE r1, r2, r3",
+ "USE SECONDARY ROLES r1, r2, r3",
+ );
}
#[test]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]