@@ -516,6 +516,7 @@ impl<'a> Parser<'a> {
516516 Keyword :: MERGE => Ok ( self . parse_merge ( ) ?) ,
517517 // `PRAGMA` is sqlite specific https://www.sqlite.org/pragma.html
518518 Keyword :: PRAGMA => Ok ( self . parse_pragma ( ) ?) ,
519+ Keyword :: UNLOAD => Ok ( self . parse_unload ( ) ?) ,
519520 // `INSTALL` is duckdb specific https://duckdb.org/docs/extensions/overview
520521 Keyword :: INSTALL if dialect_of ! ( self is DuckDbDialect | GenericDialect ) => {
521522 Ok ( self . parse_install ( ) ?)
@@ -524,7 +525,6 @@ impl<'a> Parser<'a> {
524525 Keyword :: LOAD if dialect_of ! ( self is DuckDbDialect | GenericDialect ) => {
525526 Ok ( self . parse_load ( ) ?)
526527 }
527-
528528 _ => self . expected ( "an SQL statement" , next_token) ,
529529 } ,
530530 Token :: LParen => {
@@ -8947,6 +8947,23 @@ impl<'a> Parser<'a> {
89478947 } )
89488948 }
89498949
8950+ pub fn parse_unload ( & mut self ) -> Result < Statement , ParserError > {
8951+ self . expect_token ( & Token :: LParen ) ?;
8952+ let query = self . parse_query ( ) ?;
8953+ self . expect_token ( & Token :: RParen ) ?;
8954+
8955+ self . expect_keyword ( Keyword :: TO ) ?;
8956+ let to = self . parse_identifier ( false ) ?;
8957+
8958+ let with_options = self . parse_options ( Keyword :: WITH ) ?;
8959+
8960+ Ok ( Statement :: Unload {
8961+ query : Box :: new ( query) ,
8962+ to,
8963+ with : with_options,
8964+ } )
8965+ }
8966+
89508967 pub fn parse_merge_clauses ( & mut self ) -> Result < Vec < MergeClause > , ParserError > {
89518968 let mut clauses: Vec < MergeClause > = vec ! [ ] ;
89528969 loop {
0 commit comments