Skip to content

Snowflake: CREATE USER #1950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

yoavcloud
Copy link
Contributor

Added support for the CREATE USER statement in Snowflake. Enhanced the KeyValueOptions struct with:

  1. A custom delimiter
  2. Optional parentheses
  3. Optional keywords that indicate the end of the options section

#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub struct CreateUser {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a description and link to the snowflake docs here as well? I think its usually more visible on the struct than on the enum variant since the struct is usually referenced in different contexts

@@ -4689,6 +4696,32 @@ impl<'a> Parser<'a> {
}
}

pub fn parse_create_user(&mut self, or_replace: bool) -> Result<Statement, ParserError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn parse_create_user(&mut self, or_replace: bool) -> Result<Statement, ParserError> {
fn parse_create_user(&mut self, or_replace: bool) -> Result<Statement, ParserError> {

Ok(options)
}

// Parses a `KEY = VALUE` construct based on the specified key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Parses a `KEY = VALUE` construct based on the specified key
/// Parses a `KEY = VALUE` construct based on the specified key

Comment on lines 16594 to 16606
if self.parse_keyword(Keyword::TRUE) {
Ok(KeyValueOption {
option_name: key.value,
option_type: KeyValueOptionType::BOOLEAN,
value: "TRUE".to_string(),
})
} else if self.parse_keyword(Keyword::FALSE) {
Ok(KeyValueOption {
option_name: key.value,
option_type: KeyValueOptionType::BOOLEAN,
value: "FALSE".to_string(),
})
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would something like this be equivalent and simplify the if/elseif branches?

if let Some(kw) = self.parse_one_of_keywords(&[Keyword::TRUE, Keyword::FALSE]) {
    Ok(KeyValueOption{ ..., kw.to_string() })
} else {
    // ...
}


#[test]
fn parse_create_user() {
verified_stmt("CREATE USER u1");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include in one of the scenarios an assertion on the returned AST?

@yoavcloud yoavcloud requested a review from iffyio July 21, 2025 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants