Skip to content

Commit c751911

Browse files
committed
feat: support multiple cast in all db
1 parent 05e3546 commit c751911

16 files changed

Lines changed: 186 additions & 197 deletions

pegjs/athena.pegjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,7 @@ cast_expr
22502250
keyword: c.toLowerCase(),
22512251
expr: e,
22522252
symbol: 'as',
2253-
target: t
2253+
target: [t]
22542254
};
22552255
}
22562256
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ RPAREN __ RPAREN {
@@ -2259,9 +2259,9 @@ cast_expr
22592259
keyword: c.toLowerCase(),
22602260
expr: e,
22612261
symbol: 'as',
2262-
target: {
2262+
target: [{
22632263
dataType: 'DECIMAL(' + precision + ')'
2264-
}
2264+
}]
22652265
};
22662266
}
22672267
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ COMMA __ scale:int __ RPAREN __ RPAREN {
@@ -2270,9 +2270,9 @@ cast_expr
22702270
keyword: c.toLowerCase(),
22712271
expr: e,
22722272
symbol: 'as',
2273-
target: {
2273+
target: [{
22742274
dataType: 'DECIMAL(' + precision + ', ' + scale + ')'
2275-
}
2275+
}]
22762276
};
22772277
}
22782278
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ s:signedness __ t:KW_INTEGER? __ RPAREN { /* MySQL cast to un-/signed integer */
@@ -2281,9 +2281,9 @@ cast_expr
22812281
keyword: c.toLowerCase(),
22822282
expr: e,
22832283
symbol: 'as',
2284-
target: {
2284+
target: [{
22852285
dataType: s + (t ? ' ' + t: '')
2286-
}
2286+
}]
22872287
};
22882288
}
22892289

pegjs/bigquery.pegjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,7 +2763,7 @@ cast_expr
27632763
keyword: c.toLowerCase(),
27642764
expr: e,
27652765
symbol: 'as',
2766-
target: t
2766+
target: [t]
27672767
};
27682768
}
27692769
/ c:cast_keyword __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ RPAREN __ RPAREN {
@@ -2772,9 +2772,9 @@ cast_expr
27722772
keyword: c.toLowerCase(),
27732773
expr: e,
27742774
symbol: 'as',
2775-
target: {
2775+
target: [{
27762776
dataType: 'DECIMAL(' + precision + ')'
2777-
}
2777+
}]
27782778
};
27792779
}
27802780
/ c:cast_keyword __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ COMMA __ scale:int __ RPAREN __ RPAREN {
@@ -2783,9 +2783,9 @@ cast_expr
27832783
keyword: c.toLowerCase(),
27842784
expr: e,
27852785
symbol: 'as',
2786-
target: {
2786+
target: [{
27872787
dataType: 'DECIMAL(' + precision + ', ' + scale + ')'
2788-
}
2788+
}]
27892789
};
27902790
}
27912791
/ c:cast_keyword __ LPAREN __ e:expr __ KW_AS __ s:signedness __ t:KW_INTEGER? __ RPAREN { /* MySQL cast to un-/signed integer */
@@ -2794,9 +2794,9 @@ cast_expr
27942794
keyword: c.toLowerCase(),
27952795
expr: e,
27962796
symbol: 'as',
2797-
target: {
2797+
target: [{
27982798
dataType: s + (t ? ' ' + t: '')
2799-
}
2799+
}]
28002800
};
28012801
}
28022802

pegjs/db2.pegjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ cast_expr
20592059
keyword: c.toLowerCase(),
20602060
expr: e,
20612061
symbol: 'as',
2062-
target: t
2062+
target: [t]
20632063
};
20642064
}
20652065
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ RPAREN __ RPAREN {
@@ -2068,9 +2068,9 @@ cast_expr
20682068
keyword: c.toLowerCase(),
20692069
expr: e,
20702070
symbol: 'as',
2071-
target: {
2071+
target: [{
20722072
dataType: 'DECIMAL(' + precision + ')'
2073-
}
2073+
}]
20742074
};
20752075
}
20762076
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ COMMA __ scale:int __ RPAREN __ RPAREN {
@@ -2079,9 +2079,9 @@ cast_expr
20792079
keyword: c.toLowerCase(),
20802080
expr: e,
20812081
symbol: 'as',
2082-
target: {
2082+
target: [{
20832083
dataType: 'DECIMAL(' + precision + ', ' + scale + ')'
2084-
}
2084+
}]
20852085
};
20862086
}
20872087
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ s:signedness __ t:KW_INTEGER? __ RPAREN { /* MySQL cast to un-/signed integer */
@@ -2090,9 +2090,9 @@ cast_expr
20902090
keyword: c.toLowerCase(),
20912091
expr: e,
20922092
symbol: 'as',
2093-
target: {
2093+
target: [{
20942094
dataType: s + (t ? ' ' + t: '')
2095-
}
2095+
}]
20962096
};
20972097
}
20982098

pegjs/flinksql.pegjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,7 @@ column_list_item
17321732
type: 'cast',
17331733
expr: e,
17341734
symbol: '::',
1735-
target: t
1735+
target: [t]
17361736
}
17371737
}
17381738
/ tbl:(ident __ DOT)? __ STAR {
@@ -3128,7 +3128,7 @@ cast_expr
31283128
keyword: 'cast',
31293129
expr: e,
31303130
symbol: '::',
3131-
target: t
3131+
target: [t]
31323132
}
31333133
}
31343134
/ c:(KW_CAST / KW_TRY_CAST) __ LPAREN __ e:expr __ KW_AS __ t:data_type __ RPAREN {
@@ -3137,7 +3137,7 @@ cast_expr
31373137
keyword: c.toLowerCase(),
31383138
expr: e,
31393139
symbol: 'as',
3140-
target: t
3140+
target: [t]
31413141
};
31423142
}
31433143
/ c:(KW_CAST / KW_TRY_CAST) __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ RPAREN __ RPAREN {
@@ -3146,9 +3146,9 @@ cast_expr
31463146
keyword: c.toLowerCase(),
31473147
expr: e,
31483148
symbol: 'as',
3149-
target: {
3149+
target: [{
31503150
dataType: 'DECIMAL(' + precision + ')'
3151-
}
3151+
}]
31523152
};
31533153
}
31543154
/ c:(KW_CAST / KW_TRY_CAST) __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ COMMA __ scale:int __ RPAREN __ RPAREN {
@@ -3157,9 +3157,9 @@ cast_expr
31573157
keyword: c.toLowerCase(),
31583158
expr: e,
31593159
symbol: 'as',
3160-
target: {
3160+
target: [{
31613161
dataType: 'DECIMAL(' + precision + ', ' + scale + ')'
3162-
}
3162+
}]
31633163
};
31643164
}
31653165
/ c:(KW_CAST / KW_TRY_CAST) __ LPAREN __ e:expr __ KW_AS __ s:signedness __ t:KW_INTEGER? __ RPAREN { /* MySQL cast to un-/signed integer */
@@ -3168,9 +3168,9 @@ cast_expr
31683168
keyword: c.toLowerCase(),
31693169
expr: e,
31703170
symbol: 'as',
3171-
target: {
3171+
target: [{
31723172
dataType: s + (t ? ' ' + t: '')
3173-
}
3173+
}]
31743174
};
31753175
}
31763176

pegjs/hive.pegjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,7 @@ cast_expr
20712071
keyword: c.toLowerCase(),
20722072
expr: e,
20732073
symbol: 'as',
2074-
target: t
2074+
target: [t]
20752075
};
20762076
}
20772077
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ RPAREN __ RPAREN {
@@ -2080,9 +2080,9 @@ cast_expr
20802080
keyword: c.toLowerCase(),
20812081
expr: e,
20822082
symbol: 'as',
2083-
target: {
2083+
target: [{
20842084
dataType: 'DECIMAL(' + precision + ')'
2085-
}
2085+
}]
20862086
};
20872087
}
20882088
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ COMMA __ scale:int __ RPAREN __ RPAREN {
@@ -2091,9 +2091,9 @@ cast_expr
20912091
keyword: c.toLowerCase(),
20922092
expr: e,
20932093
symbol: 'as',
2094-
target: {
2094+
target: [{
20952095
dataType: 'DECIMAL(' + precision + ', ' + scale + ')'
2096-
}
2096+
}]
20972097
};
20982098
}
20992099
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ s:signedness __ t:KW_INTEGER? __ RPAREN { /* MySQL cast to un-/signed integer */
@@ -2102,9 +2102,9 @@ cast_expr
21022102
keyword: c.toLowerCase(),
21032103
expr: e,
21042104
symbol: 'as',
2105-
target: {
2105+
target: [{
21062106
dataType: s + (t ? ' ' + t: '')
2107-
}
2107+
}]
21082108
};
21092109
}
21102110

pegjs/mariadb.pegjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3328,10 +3328,10 @@ cast_expr
33283328
keyword: c.toLowerCase(),
33293329
expr: e,
33303330
symbol: 'as',
3331-
target: {
3331+
target: [{
33323332
dataType: dataTypeStr,
33333333
suffix: [{ type: 'origin', value: cs }, v],
3334-
},
3334+
}],
33353335
};
33363336
}
33373337
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ t:data_type __ RPAREN {
@@ -3340,7 +3340,7 @@ cast_expr
33403340
keyword: c.toLowerCase(),
33413341
expr: e,
33423342
symbol: 'as',
3343-
target: t
3343+
target: [t]
33443344
};
33453345
}
33463346
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ RPAREN __ RPAREN {
@@ -3349,9 +3349,9 @@ cast_expr
33493349
keyword: c.toLowerCase(),
33503350
expr: e,
33513351
symbol: 'as',
3352-
target: {
3352+
target: [{
33533353
dataType: 'DECIMAL(' + precision + ')'
3354-
}
3354+
}]
33553355
};
33563356
}
33573357
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ COMMA __ scale:int __ RPAREN __ RPAREN {
@@ -3360,9 +3360,9 @@ cast_expr
33603360
keyword: c.toLowerCase(),
33613361
expr: e,
33623362
symbol: 'as',
3363-
target: {
3363+
target: [{
33643364
dataType: 'DECIMAL(' + precision + ', ' + scale + ')'
3365-
}
3365+
}]
33663366
};
33673367
}
33683368
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ s:signedness __ t:KW_INTEGER? __ RPAREN { /* MySQL cast to un-/signed integer */
@@ -3371,9 +3371,9 @@ cast_expr
33713371
keyword: c.toLowerCase(),
33723372
expr: e,
33733373
symbol: 'as',
3374-
target: {
3374+
target: [{
33753375
dataType: [s, t].filter(Boolean).join(' ')
3376-
}
3376+
}]
33773377
};
33783378
}
33793379

pegjs/mysql.pegjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3617,10 +3617,10 @@ cast_expr
36173617
keyword: c.toLowerCase(),
36183618
expr: e,
36193619
symbol: 'as',
3620-
target: {
3620+
target: [{
36213621
dataType: dataTypeStr,
36223622
suffix: [{ type: 'origin', value: cs }, v],
3623-
},
3623+
}],
36243624
};
36253625
}
36263626
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ t:data_type __ RPAREN {
@@ -3629,7 +3629,7 @@ cast_expr
36293629
keyword: c.toLowerCase(),
36303630
expr: e,
36313631
symbol: 'as',
3632-
target: t
3632+
target: [t]
36333633
};
36343634
}
36353635
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ RPAREN __ RPAREN {
@@ -3638,9 +3638,9 @@ cast_expr
36383638
keyword: c.toLowerCase(),
36393639
expr: e,
36403640
symbol: 'as',
3641-
target: {
3641+
target: [{
36423642
dataType: 'DECIMAL(' + precision + ')'
3643-
}
3643+
}]
36443644
};
36453645
}
36463646
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ COMMA __ scale:int __ RPAREN __ RPAREN {
@@ -3649,9 +3649,9 @@ cast_expr
36493649
keyword: c.toLowerCase(),
36503650
expr: e,
36513651
symbol: 'as',
3652-
target: {
3652+
target: [{
36533653
dataType: 'DECIMAL(' + precision + ', ' + scale + ')'
3654-
}
3654+
}]
36553655
};
36563656
}
36573657
/ c:KW_CAST __ LPAREN __ e:expr __ KW_AS __ s:signedness __ t:KW_INTEGER? __ RPAREN { /* MySQL cast to un-/signed integer */
@@ -3660,9 +3660,9 @@ cast_expr
36603660
keyword: c.toLowerCase(),
36613661
expr: e,
36623662
symbol: 'as',
3663-
target: {
3663+
target: [{
36643664
dataType: [s, t].filter(Boolean).join(' ')
3665-
}
3665+
}]
36663666
};
36673667
}
36683668

0 commit comments

Comments
 (0)