@@ -227,7 +227,7 @@ pub fn statement_body(i: Input) -> IResult<Statement> {
227227 rule ! {
228228 MERGE ~ #hint?
229229 ~ INTO ~ #dot_separated_idents_1_to_3 ~ #table_alias?
230- ~ USING ~ #merge_source
230+ ~ USING ~ #mutation_source
231231 ~ ON ~ #expr ~ ( #match_clause | #unmatch_clause) *
232232 } ,
233233 |(
@@ -271,15 +271,30 @@ pub fn statement_body(i: Input) -> IResult<Statement> {
271271
272272 let update = map (
273273 rule ! {
274- #with? ~ UPDATE ~ #hint? ~ #table_reference_only
275- ~ SET ~ ^#comma_separated_list1( update_expr)
274+ #with? ~ UPDATE ~ #hint? ~ #dot_separated_idents_1_to_3 ~ #table_alias?
275+ ~ SET ~ ^#comma_separated_list1( mutation_update_expr)
276+ ~ ( FROM ~ #mutation_source ) ?
276277 ~ ( WHERE ~ ^#expr ) ?
277278 } ,
278- |( with, _, hints, table, _, update_list, opt_selection) | {
279+ |(
280+ with,
281+ _,
282+ hints,
283+ ( catalog, database, table) ,
284+ table_alias,
285+ _,
286+ update_list,
287+ from,
288+ opt_selection,
289+ ) | {
279290 Statement :: Update ( UpdateStmt {
280291 hints,
292+ catalog,
293+ database,
281294 table,
295+ table_alias,
282296 update_list,
297+ from : from. map ( |( _, table) | table) ,
283298 selection : opt_selection. map ( |( _, selection) | selection) ,
284299 with,
285300 } )
@@ -2899,28 +2914,28 @@ pub fn raw_insert_source(i: Input) -> IResult<InsertSource> {
28992914 ) ( i)
29002915}
29012916
2902- pub fn merge_source ( i : Input ) -> IResult < MergeSource > {
2917+ pub fn mutation_source ( i : Input ) -> IResult < MutationSource > {
29032918 let streaming_v2 = map (
29042919 rule ! {
29052920 #file_format_clause ~ ( ON_ERROR ~ ^"=" ~ ^#ident) ? ~ #rest_str
29062921 } ,
2907- |( options, on_error_opt, ( _, start) ) | MergeSource :: StreamingV2 {
2922+ |( options, on_error_opt, ( _, start) ) | MutationSource :: StreamingV2 {
29082923 settings : options,
29092924 on_error_mode : on_error_opt. map ( |v| v. 2 . to_string ( ) ) ,
29102925 start,
29112926 } ,
29122927 ) ;
29132928
29142929 let query = map ( rule ! { #query ~ #table_alias} , |( query, source_alias) | {
2915- MergeSource :: Select {
2930+ MutationSource :: Select {
29162931 query : Box :: new ( query) ,
29172932 source_alias,
29182933 }
29192934 } ) ;
29202935
29212936 let source_table = map (
29222937 rule ! ( #dot_separated_idents_1_to_3 ~ #with_options? ~ #table_alias?) ,
2923- |( ( catalog, database, table) , with_options, alias) | MergeSource :: Table {
2938+ |( ( catalog, database, table) , with_options, alias) | MutationSource :: Table {
29242939 catalog,
29252940 database,
29262941 table,
@@ -3813,7 +3828,7 @@ fn match_operation(i: Input) -> IResult<MatchOperation> {
38133828 value ( MatchOperation :: Delete , rule ! { DELETE } ) ,
38143829 map (
38153830 rule ! {
3816- UPDATE ~ SET ~ ^#comma_separated_list1( merge_update_expr )
3831+ UPDATE ~ SET ~ ^#comma_separated_list1( mutation_update_expr )
38173832 } ,
38183833 |( _, _, update_list) | MatchOperation :: Update {
38193834 update_list,
@@ -4640,10 +4655,10 @@ pub fn udf_definition(i: Input) -> IResult<UDFDefinition> {
46404655 ) ( i)
46414656}
46424657
4643- pub fn merge_update_expr ( i : Input ) -> IResult < MergeUpdateExpr > {
4658+ pub fn mutation_update_expr ( i : Input ) -> IResult < MutationUpdateExpr > {
46444659 map (
46454660 rule ! { #dot_separated_idents_1_to_2 ~ "=" ~ ^#expr } ,
4646- |( ( table, name) , _, expr) | MergeUpdateExpr { table, name, expr } ,
4661+ |( ( table, name) , _, expr) | MutationUpdateExpr { table, name, expr } ,
46474662 ) ( i)
46484663}
46494664
0 commit comments