@@ -5403,6 +5403,8 @@ impl<'a> Parser<'a> {
54035403 self.parse_create_user(or_replace).map(Into::into)
54045404 } else if self.parse_keyword(Keyword::WAREHOUSE) {
54055405 self.parse_create_warehouse(or_replace)
5406+ } else if self.parse_keyword(Keyword::ACCOUNT) {
5407+ self.parse_create_account()
54065408 } else if self.parse_keyword(Keyword::TASK) {
54075409 self.parse_create_task(or_replace)
54085410 } else if self.parse_keyword(Keyword::PROCEDURE) {
@@ -5497,6 +5499,31 @@ impl<'a> Parser<'a> {
54975499 })
54985500 }
54995501
5502+ fn parse_create_account(&mut self) -> Result<Statement, ParserError> {
5503+ let name = self.parse_identifier()?;
5504+ let mut options = Vec::new();
5505+ while let Token::Word(_) = self.peek_token_ref().token {
5506+ let name = self.parse_identifier()?;
5507+ self.expect_token(&Token::Eq)?;
5508+ let value = self.parse_expr()?;
5509+ options.push(AccountOption { name, value });
5510+ }
5511+ Ok(Statement::CreateAccount { name, options })
5512+ }
5513+
5514+ fn parse_drop_account(&mut self) -> Result<Statement, ParserError> {
5515+ let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]);
5516+ let name = self.parse_identifier()?;
5517+ self.expect_keyword(Keyword::GRACE_PERIOD_IN_DAYS)?;
5518+ self.expect_token(&Token::Eq)?;
5519+ let grace_period_in_days = self.parse_expr()?;
5520+ Ok(Statement::DropAccount {
5521+ if_exists,
5522+ name,
5523+ grace_period_in_days,
5524+ })
5525+ }
5526+
55005527 /// Parse `CREATE [OR REPLACE] TASK [IF NOT EXISTS] <name> ... AS <statement>`.
55015528 fn parse_create_task(&mut self, or_replace: bool) -> Result<Statement, ParserError> {
55025529 let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
@@ -7699,6 +7726,8 @@ impl<'a> Parser<'a> {
76997726 ObjectType::Stream
77007727 } else if self.parse_keyword(Keyword::WAREHOUSE) {
77017728 ObjectType::Warehouse
7729+ } else if self.parse_keyword(Keyword::ACCOUNT) {
7730+ return self.parse_drop_account();
77027731 } else if self.parse_keyword(Keyword::TASK) {
77037732 ObjectType::Task
77047733 } else if self.parse_keyword(Keyword::FUNCTION) {
@@ -11069,6 +11098,7 @@ impl<'a> Parser<'a> {
1106911098 Keyword::USER,
1107011099 Keyword::OPERATOR,
1107111100 Keyword::WAREHOUSE,
11101+ Keyword::ACCOUNT,
1107211102 Keyword::TASK,
1107311103 ])?;
1107411104 match object_type {
@@ -11119,10 +11149,11 @@ impl<'a> Parser<'a> {
1111911149 Keyword::CONNECTOR => self.parse_alter_connector(),
1112011150 Keyword::USER => self.parse_alter_user().map(Into::into),
1112111151 Keyword::WAREHOUSE => self.parse_alter_warehouse(),
11152+ Keyword::ACCOUNT => self.parse_alter_account(),
1112211153 Keyword::TASK => self.parse_alter_task(),
1112311154 // unreachable because expect_one_of_keywords used above
1112411155 unexpected_keyword => Err(ParserError::ParserError(
11125- format!("Internal parser error: expected any of {{VIEW, TYPE, COLLATION, TABLE, INDEX, FUNCTION, AGGREGATE, ROLE, POLICY, CONNECTOR, ICEBERG, SCHEMA, USER, OPERATOR, WAREHOUSE, TASK}}, got {unexpected_keyword:?}"),
11156+ format!("Internal parser error: expected any of {{VIEW, TYPE, COLLATION, TABLE, INDEX, FUNCTION, AGGREGATE, ROLE, POLICY, CONNECTOR, ICEBERG, SCHEMA, USER, OPERATOR, WAREHOUSE, ACCOUNT, TASK}}, got {unexpected_keyword:?}"),
1112611157 )),
1112711158 }
1112811159 }
@@ -11409,6 +11440,41 @@ impl<'a> Parser<'a> {
1140911440 })
1141011441 }
1141111442
11443+ fn parse_alter_account(&mut self) -> Result<Statement, ParserError> {
11444+ // The name is optional — bare `ALTER ACCOUNT SET ...` targets the
11445+ // current account. SET and RENAME are the only operations, so their
11446+ // presence indicates no name was provided.
11447+ let starts_with_op = matches!(
11448+ self.peek_token().token,
11449+ Token::Word(ref w) if matches!(w.keyword, Keyword::SET | Keyword::RENAME)
11450+ );
11451+ let name = if starts_with_op {
11452+ None
11453+ } else {
11454+ Some(self.parse_identifier()?)
11455+ };
11456+
11457+ let operation = if self.parse_keywords(&[Keyword::RENAME, Keyword::TO]) {
11458+ let new_name = self.parse_identifier()?;
11459+ AlterAccountOperation::RenameTo { new_name }
11460+ } else if self.parse_keyword(Keyword::SET) {
11461+ let params = self.parse_comma_separated(|p| {
11462+ let name = p.parse_identifier()?;
11463+ p.expect_token(&Token::Eq)?;
11464+ let value = p.parse_expr()?;
11465+ Ok::<AccountOption, ParserError>(AccountOption { name, value })
11466+ })?;
11467+ AlterAccountOperation::Set { params }
11468+ } else {
11469+ return self.expected(
11470+ "SET or RENAME TO after ALTER ACCOUNT",
11471+ self.peek_token(),
11472+ );
11473+ };
11474+
11475+ Ok(Statement::AlterAccount { name, operation })
11476+ }
11477+
1141211478 /// Parse `ALTER TASK [IF EXISTS] <name> { RESUME | SUSPEND }`.
1141311479 pub fn parse_alter_task(&mut self) -> Result<Statement, ParserError> {
1141411480 let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]);
0 commit comments