Skip to content

Snowflake: Add support for CREATE USER#1950

Merged
iffyio merged 2 commits intoapache:mainfrom
yoavcloud:sf_create_user
Jul 23, 2025
Merged

Snowflake: Add support for CREATE USER#1950
iffyio merged 2 commits intoapache:mainfrom
yoavcloud:sf_create_user

Conversation

@yoavcloud
Copy link
Copy Markdown
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

Comment thread src/ast/mod.rs
#[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
Copy Markdown
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

Comment thread src/parser/mod.rs Outdated
}
}

pub fn parse_create_user(&mut self, or_replace: bool) -> Result<Statement, ParserError> {
Copy link
Copy Markdown
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> {

Comment thread src/parser/mod.rs Outdated
Ok(options)
}

// Parses a `KEY = VALUE` construct based on the specified key
Copy link
Copy Markdown
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 thread src/parser/mod.rs Outdated
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
Copy Markdown
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 {
    // ...
}

Comment thread tests/sqlparser_common.rs Outdated

#[test]
fn parse_create_user() {
verified_stmt("CREATE USER u1");
Copy link
Copy Markdown
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
@iffyio iffyio changed the title Snowflake: CREATE USER Snowflake: Add support for CREATE USER Jul 23, 2025
Copy link
Copy Markdown
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @yoavcloud!
cc @alamb

@iffyio iffyio merged commit 2ed2cbe into apache:main Jul 23, 2025
10 checks passed
ayman-sigma pushed a commit to sigmacomputing/sqlparser-rs that referenced this pull request Feb 3, 2026
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