@@ -607,19 +607,19 @@ impl<'a> Parser<'a> {
607607 Keyword::ANALYZE => self.parse_analyze(),
608608 Keyword::CASE => {
609609 self.prev_token();
610- self.parse_case_stmt()
610+ self.parse_case_stmt().map(Into::into)
611611 }
612612 Keyword::IF => {
613613 self.prev_token();
614- self.parse_if_stmt()
614+ self.parse_if_stmt().map(Into::into)
615615 }
616616 Keyword::WHILE => {
617617 self.prev_token();
618- self.parse_while()
618+ self.parse_while().map(Into::into)
619619 }
620620 Keyword::RAISE => {
621621 self.prev_token();
622- self.parse_raise_stmt()
622+ self.parse_raise_stmt().map(Into::into)
623623 }
624624 Keyword::SELECT | Keyword::WITH | Keyword::VALUES | Keyword::FROM => {
625625 self.prev_token();
@@ -679,7 +679,7 @@ impl<'a> Parser<'a> {
679679 Keyword::DEALLOCATE => self.parse_deallocate(),
680680 Keyword::EXECUTE | Keyword::EXEC => self.parse_execute(),
681681 Keyword::PREPARE => self.parse_prepare(),
682- Keyword::MERGE => self.parse_merge(next_token),
682+ Keyword::MERGE => self.parse_merge(next_token).map(Into::into) ,
683683 // `LISTEN`, `UNLISTEN` and `NOTIFY` are Postgres-specific
684684 // syntaxes. They are used for Postgres statement.
685685 Keyword::LISTEN if self.dialect.supports_listen_notify() => self.parse_listen(),
@@ -727,7 +727,7 @@ impl<'a> Parser<'a> {
727727 /// Parse a `CASE` statement.
728728 ///
729729 /// See [Statement::Case]
730- pub fn parse_case_stmt(&mut self) -> Result<Statement , ParserError> {
730+ pub fn parse_case_stmt(&mut self) -> Result<CaseStatement , ParserError> {
731731 let case_token = self.expect_keyword(Keyword::CASE)?;
732732
733733 let match_expr = if self.peek_keyword(Keyword::WHEN) {
@@ -752,19 +752,19 @@ impl<'a> Parser<'a> {
752752 end_case_token = self.expect_keyword(Keyword::CASE)?;
753753 }
754754
755- Ok(Statement::Case( CaseStatement {
755+ Ok(CaseStatement {
756756 case_token: AttachedToken(case_token),
757757 match_expr,
758758 when_blocks,
759759 else_block,
760760 end_case_token: AttachedToken(end_case_token),
761- }))
761+ })
762762 }
763763
764764 /// Parse an `IF` statement.
765765 ///
766766 /// See [Statement::If]
767- pub fn parse_if_stmt(&mut self) -> Result<Statement , ParserError> {
767+ pub fn parse_if_stmt(&mut self) -> Result<IfStatement , ParserError> {
768768 self.expect_keyword_is(Keyword::IF)?;
769769 let if_block = self.parse_conditional_statement_block(&[
770770 Keyword::ELSE,
@@ -793,22 +793,22 @@ impl<'a> Parser<'a> {
793793 self.expect_keyword_is(Keyword::END)?;
794794 let end_token = self.expect_keyword(Keyword::IF)?;
795795
796- Ok(Statement::If( IfStatement {
796+ Ok(IfStatement {
797797 if_block,
798798 elseif_blocks,
799799 else_block,
800800 end_token: Some(AttachedToken(end_token)),
801- }))
801+ })
802802 }
803803
804804 /// Parse a `WHILE` statement.
805805 ///
806806 /// See [Statement::While]
807- fn parse_while(&mut self) -> Result<Statement , ParserError> {
807+ fn parse_while(&mut self) -> Result<WhileStatement , ParserError> {
808808 self.expect_keyword_is(Keyword::WHILE)?;
809809 let while_block = self.parse_conditional_statement_block(&[Keyword::END])?;
810810
811- Ok(Statement::While( WhileStatement { while_block }) )
811+ Ok(WhileStatement { while_block })
812812 }
813813
814814 /// Parses an expression and associated list of statements
@@ -875,7 +875,7 @@ impl<'a> Parser<'a> {
875875 /// Parse a `RAISE` statement.
876876 ///
877877 /// See [Statement::Raise]
878- pub fn parse_raise_stmt(&mut self) -> Result<Statement , ParserError> {
878+ pub fn parse_raise_stmt(&mut self) -> Result<RaiseStatement , ParserError> {
879879 self.expect_keyword_is(Keyword::RAISE)?;
880880
881881 let value = if self.parse_keywords(&[Keyword::USING, Keyword::MESSAGE]) {
@@ -885,7 +885,7 @@ impl<'a> Parser<'a> {
885885 self.maybe_parse(|parser| parser.parse_expr().map(RaiseStatementValue::Expr))?
886886 };
887887
888- Ok(Statement::Raise( RaiseStatement { value }) )
888+ Ok(RaiseStatement { value })
889889 }
890890 /// Parse a COMMENT statement.
891891 ///
@@ -1432,7 +1432,7 @@ impl<'a> Parser<'a> {
14321432
14331433 Ok(RenameTable { old_name, new_name })
14341434 })?;
1435- Ok(Statement::RenameTable( rename_tables))
1435+ Ok(rename_tables.into( ))
14361436 } else {
14371437 self.expected("KEYWORD `TABLE` after RENAME", self.peek_token())
14381438 }
@@ -4898,7 +4898,7 @@ impl<'a> Parser<'a> {
48984898 } else if self.parse_keyword(Keyword::SECRET) {
48994899 self.parse_create_secret(or_replace, temporary, persistent)
49004900 } else if self.parse_keyword(Keyword::USER) {
4901- self.parse_create_user(or_replace)
4901+ self.parse_create_user(or_replace).map(Into::into)
49024902 } else if or_replace {
49034903 self.expected(
49044904 "[EXTERNAL] TABLE or [MATERIALIZED] VIEW or FUNCTION after CREATE OR REPLACE",
@@ -4942,7 +4942,7 @@ impl<'a> Parser<'a> {
49424942 }
49434943 }
49444944
4945- fn parse_create_user(&mut self, or_replace: bool) -> Result<Statement , ParserError> {
4945+ fn parse_create_user(&mut self, or_replace: bool) -> Result<CreateUser , ParserError> {
49464946 let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
49474947 let name = self.parse_identifier()?;
49484948 let options = self
@@ -4954,7 +4954,7 @@ impl<'a> Parser<'a> {
49544954 } else {
49554955 vec![]
49564956 };
4957- Ok(Statement::CreateUser( CreateUser {
4957+ Ok(CreateUser {
49584958 or_replace,
49594959 if_not_exists,
49604960 name,
@@ -4967,7 +4967,7 @@ impl<'a> Parser<'a> {
49674967 options: tags,
49684968 delimiter: KeyValueOptionsDelimiter::Comma,
49694969 },
4970- }))
4970+ })
49714971 }
49724972
49734973 /// See [DuckDB Docs](https://duckdb.org/docs/sql/statements/create_secret.html) for more details.
@@ -10158,17 +10158,17 @@ impl<'a> Parser<'a> {
1015810158 }
1015910159 Keyword::OPERATOR => {
1016010160 if self.parse_keyword(Keyword::FAMILY) {
10161- self.parse_alter_operator_family()
10161+ self.parse_alter_operator_family().map(Into::into)
1016210162 } else if self.parse_keyword(Keyword::CLASS) {
10163- self.parse_alter_operator_class()
10163+ self.parse_alter_operator_class().map(Into::into)
1016410164 } else {
10165- self.parse_alter_operator()
10165+ self.parse_alter_operator().map(Into::into)
1016610166 }
1016710167 }
1016810168 Keyword::ROLE => self.parse_alter_role(),
1016910169 Keyword::POLICY => self.parse_alter_policy(),
1017010170 Keyword::CONNECTOR => self.parse_alter_connector(),
10171- Keyword::USER => self.parse_alter_user(),
10171+ Keyword::USER => self.parse_alter_user().map(Into::into) ,
1017210172 // unreachable because expect_one_of_keywords used above
1017310173 unexpected_keyword => Err(ParserError::ParserError(
1017410174 format!("Internal parser error: expected any of {{VIEW, TYPE, TABLE, INDEX, ROLE, POLICY, CONNECTOR, ICEBERG, SCHEMA, USER, OPERATOR}}, got {unexpected_keyword:?}"),
@@ -10290,7 +10290,7 @@ impl<'a> Parser<'a> {
1029010290 /// Parse a [Statement::AlterOperator]
1029110291 ///
1029210292 /// [PostgreSQL Documentation](https://www.postgresql.org/docs/current/sql-alteroperator.html)
10293- pub fn parse_alter_operator(&mut self) -> Result<Statement , ParserError> {
10293+ pub fn parse_alter_operator(&mut self) -> Result<AlterOperator , ParserError> {
1029410294 let name = self.parse_operator_name()?;
1029510295
1029610296 // Parse (left_type, right_type)
@@ -10389,12 +10389,12 @@ impl<'a> Parser<'a> {
1038910389 );
1039010390 };
1039110391
10392- Ok(Statement::AlterOperator( AlterOperator {
10392+ Ok(AlterOperator {
1039310393 name,
1039410394 left_type,
1039510395 right_type,
1039610396 operation,
10397- }))
10397+ })
1039810398 }
1039910399
1040010400 /// Parse an operator item for ALTER OPERATOR FAMILY ADD operations
@@ -10527,7 +10527,7 @@ impl<'a> Parser<'a> {
1052710527
1052810528 /// Parse a [Statement::AlterOperatorFamily]
1052910529 /// See <https://www.postgresql.org/docs/current/sql-alteropfamily.html>
10530- pub fn parse_alter_operator_family(&mut self) -> Result<Statement , ParserError> {
10530+ pub fn parse_alter_operator_family(&mut self) -> Result<AlterOperatorFamily , ParserError> {
1053110531 let name = self.parse_object_name(false)?;
1053210532 self.expect_keyword(Keyword::USING)?;
1053310533 let using = self.parse_identifier()?;
@@ -10554,17 +10554,17 @@ impl<'a> Parser<'a> {
1055410554 );
1055510555 };
1055610556
10557- Ok(Statement::AlterOperatorFamily( AlterOperatorFamily {
10557+ Ok(AlterOperatorFamily {
1055810558 name,
1055910559 using,
1056010560 operation,
10561- }))
10561+ })
1056210562 }
1056310563
1056410564 /// Parse an `ALTER OPERATOR CLASS` statement.
1056510565 ///
1056610566 /// Handles operations like `RENAME TO`, `OWNER TO`, and `SET SCHEMA`.
10567- pub fn parse_alter_operator_class(&mut self) -> Result<Statement , ParserError> {
10567+ pub fn parse_alter_operator_class(&mut self) -> Result<AlterOperatorClass , ParserError> {
1056810568 let name = self.parse_object_name(false)?;
1056910569 self.expect_keyword(Keyword::USING)?;
1057010570 let using = self.parse_identifier()?;
@@ -10585,11 +10585,11 @@ impl<'a> Parser<'a> {
1058510585 );
1058610586 };
1058710587
10588- Ok(Statement::AlterOperatorClass( AlterOperatorClass {
10588+ Ok(AlterOperatorClass {
1058910589 name,
1059010590 using,
1059110591 operation,
10592- }))
10592+ })
1059310593 }
1059410594
1059510595 /// Parse an `ALTER SCHEMA` statement.
@@ -16803,7 +16803,7 @@ impl<'a> Parser<'a> {
1680316803 None
1680416804 };
1680516805
16806- Ok(Statement::Insert( Insert {
16806+ Ok(Insert {
1680716807 insert_token: insert_token.into(),
1680816808 or,
1680916809 table: table_object,
@@ -16824,7 +16824,8 @@ impl<'a> Parser<'a> {
1682416824 insert_alias,
1682516825 settings,
1682616826 format_clause,
16827- }))
16827+ }
16828+ .into())
1682816829 }
1682916830 }
1683016831
0 commit comments