@@ -227,7 +227,7 @@ pub fn statement_body(i: Input) -> IResult<Statement> {
227
227
rule ! {
228
228
MERGE ~ #hint?
229
229
~ INTO ~ #dot_separated_idents_1_to_3 ~ #table_alias?
230
- ~ USING ~ #merge_source
230
+ ~ USING ~ #mutation_source
231
231
~ ON ~ #expr ~ ( #match_clause | #unmatch_clause) *
232
232
} ,
233
233
|(
@@ -271,15 +271,30 @@ pub fn statement_body(i: Input) -> IResult<Statement> {
271
271
272
272
let update = map (
273
273
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 ) ?
276
277
~ ( WHERE ~ ^#expr ) ?
277
278
} ,
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
+ ) | {
279
290
Statement :: Update ( UpdateStmt {
280
291
hints,
292
+ catalog,
293
+ database,
281
294
table,
295
+ table_alias,
282
296
update_list,
297
+ from : from. map ( |( _, table) | table) ,
283
298
selection : opt_selection. map ( |( _, selection) | selection) ,
284
299
with,
285
300
} )
@@ -2899,28 +2914,28 @@ pub fn raw_insert_source(i: Input) -> IResult<InsertSource> {
2899
2914
) ( i)
2900
2915
}
2901
2916
2902
- pub fn merge_source ( i : Input ) -> IResult < MergeSource > {
2917
+ pub fn mutation_source ( i : Input ) -> IResult < MutationSource > {
2903
2918
let streaming_v2 = map (
2904
2919
rule ! {
2905
2920
#file_format_clause ~ ( ON_ERROR ~ ^"=" ~ ^#ident) ? ~ #rest_str
2906
2921
} ,
2907
- |( options, on_error_opt, ( _, start) ) | MergeSource :: StreamingV2 {
2922
+ |( options, on_error_opt, ( _, start) ) | MutationSource :: StreamingV2 {
2908
2923
settings : options,
2909
2924
on_error_mode : on_error_opt. map ( |v| v. 2 . to_string ( ) ) ,
2910
2925
start,
2911
2926
} ,
2912
2927
) ;
2913
2928
2914
2929
let query = map ( rule ! { #query ~ #table_alias} , |( query, source_alias) | {
2915
- MergeSource :: Select {
2930
+ MutationSource :: Select {
2916
2931
query : Box :: new ( query) ,
2917
2932
source_alias,
2918
2933
}
2919
2934
} ) ;
2920
2935
2921
2936
let source_table = map (
2922
2937
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 {
2924
2939
catalog,
2925
2940
database,
2926
2941
table,
@@ -3813,7 +3828,7 @@ fn match_operation(i: Input) -> IResult<MatchOperation> {
3813
3828
value ( MatchOperation :: Delete , rule ! { DELETE } ) ,
3814
3829
map (
3815
3830
rule ! {
3816
- UPDATE ~ SET ~ ^#comma_separated_list1( merge_update_expr )
3831
+ UPDATE ~ SET ~ ^#comma_separated_list1( mutation_update_expr )
3817
3832
} ,
3818
3833
|( _, _, update_list) | MatchOperation :: Update {
3819
3834
update_list,
@@ -4640,10 +4655,10 @@ pub fn udf_definition(i: Input) -> IResult<UDFDefinition> {
4640
4655
) ( i)
4641
4656
}
4642
4657
4643
- pub fn merge_update_expr ( i : Input ) -> IResult < MergeUpdateExpr > {
4658
+ pub fn mutation_update_expr ( i : Input ) -> IResult < MutationUpdateExpr > {
4644
4659
map (
4645
4660
rule ! { #dot_separated_idents_1_to_2 ~ "=" ~ ^#expr } ,
4646
- |( ( table, name) , _, expr) | MergeUpdateExpr { table, name, expr } ,
4661
+ |( ( table, name) , _, expr) | MutationUpdateExpr { table, name, expr } ,
4647
4662
) ( i)
4648
4663
}
4649
4664
0 commit comments