@@ -206,15 +206,20 @@ fn test_redshift_json_path() {
206
206
let select = redshift ( ) . verified_only_select ( sql) ;
207
207
208
208
assert_eq ! (
209
- & Expr :: JsonAccess {
209
+ & Expr :: JsonAccess {
210
210
value: Box :: new( Expr :: CompoundIdentifier ( vec![
211
211
Ident :: new( "cust" ) ,
212
212
Ident :: new( "c_orders" )
213
213
] ) ) ,
214
- path: JsonPath {
214
+ path: JsonPath {
215
215
path: vec![
216
- JsonPathElem :: Bracket { key: Expr :: Value ( Value :: Number ( "0" . to_string( ) , false ) ) } ,
217
- JsonPathElem :: Dot { key: "o_orderkey" . to_string( ) , quoted: false }
216
+ JsonPathElem :: Bracket {
217
+ key: Expr :: Value ( Value :: Number ( "0" . parse( ) . unwrap( ) , false ) )
218
+ } ,
219
+ JsonPathElem :: Dot {
220
+ key: "o_orderkey" . to_string( ) ,
221
+ quoted: false
222
+ }
218
223
]
219
224
}
220
225
} ,
@@ -224,15 +229,19 @@ fn test_redshift_json_path() {
224
229
let sql = "SELECT cust.c_orders[0]['id'] FROM customer_orders_lineitem" ;
225
230
let select = redshift ( ) . verified_only_select ( sql) ;
226
231
assert_eq ! (
227
- & Expr :: JsonAccess {
232
+ & Expr :: JsonAccess {
228
233
value: Box :: new( Expr :: CompoundIdentifier ( vec![
229
234
Ident :: new( "cust" ) ,
230
235
Ident :: new( "c_orders" )
231
236
] ) ) ,
232
- path: JsonPath {
237
+ path: JsonPath {
233
238
path: vec![
234
- JsonPathElem :: Bracket { key: Expr :: Value ( Value :: Number ( "0" . to_string( ) , false ) ) } ,
235
- JsonPathElem :: Bracket { key: Expr :: Value ( Value :: SingleQuotedString ( "id" . to_owned( ) ) ) }
239
+ JsonPathElem :: Bracket {
240
+ key: Expr :: Value ( Value :: Number ( "0" . parse( ) . unwrap( ) , false ) )
241
+ } ,
242
+ JsonPathElem :: Bracket {
243
+ key: Expr :: Value ( Value :: SingleQuotedString ( "id" . to_owned( ) ) )
244
+ }
236
245
]
237
246
}
238
247
} ,
@@ -248,10 +257,15 @@ fn test_parse_json_path_from() {
248
257
assert_eq ! ( name, & ObjectName ( vec![ Ident :: new( "src" ) ] ) ) ;
249
258
assert_eq ! (
250
259
partiql,
251
- & Some ( JsonPath {
260
+ & Some ( JsonPath {
252
261
path: vec![
253
- JsonPathElem :: Bracket { key: Expr :: Value ( Value :: Number ( "0" . to_string( ) , false ) ) } ,
254
- JsonPathElem :: Dot { key: "a" . to_string( ) , quoted: false }
262
+ JsonPathElem :: Bracket {
263
+ key: Expr :: Value ( Value :: Number ( "0" . parse( ) . unwrap( ) , false ) )
264
+ } ,
265
+ JsonPathElem :: Dot {
266
+ key: "a" . to_string( ) ,
267
+ quoted: false
268
+ }
255
269
]
256
270
} )
257
271
) ;
@@ -265,12 +279,22 @@ fn test_parse_json_path_from() {
265
279
assert_eq ! ( name, & ObjectName ( vec![ Ident :: new( "src" ) ] ) ) ;
266
280
assert_eq ! (
267
281
partiql,
268
- & Some ( JsonPath {
282
+ & Some ( JsonPath {
269
283
path: vec![
270
- JsonPathElem :: Bracket { key: Expr :: Value ( Value :: Number ( "0" . to_string( ) , false ) ) } ,
271
- JsonPathElem :: Dot { key: "a" . to_string( ) , quoted: false } ,
272
- JsonPathElem :: Bracket { key: Expr :: Value ( Value :: Number ( "1" . to_string( ) , false ) ) } ,
273
- JsonPathElem :: Dot { key: "b" . to_string( ) , quoted: false } ,
284
+ JsonPathElem :: Bracket {
285
+ key: Expr :: Value ( Value :: Number ( "0" . parse( ) . unwrap( ) , false ) )
286
+ } ,
287
+ JsonPathElem :: Dot {
288
+ key: "a" . to_string( ) ,
289
+ quoted: false
290
+ } ,
291
+ JsonPathElem :: Bracket {
292
+ key: Expr :: Value ( Value :: Number ( "1" . parse( ) . unwrap( ) , false ) )
293
+ } ,
294
+ JsonPathElem :: Dot {
295
+ key: "b" . to_string( ) ,
296
+ quoted: false
297
+ } ,
274
298
]
275
299
} )
276
300
) ;
@@ -281,10 +305,12 @@ fn test_parse_json_path_from() {
281
305
let select = redshift ( ) . verified_only_select ( "SELECT * FROM src.a.b" ) ;
282
306
match & select. from [ 0 ] . relation {
283
307
TableFactor :: Table { name, partiql, .. } => {
284
- assert_eq ! ( name, & ObjectName ( vec![ Ident :: new( "src" ) , Ident :: new( "a" ) , Ident :: new( "b" ) ] ) ) ;
308
+ assert_eq ! (
309
+ name,
310
+ & ObjectName ( vec![ Ident :: new( "src" ) , Ident :: new( "a" ) , Ident :: new( "b" ) ] )
311
+ ) ;
285
312
assert_eq ! ( partiql, & None ) ;
286
313
}
287
314
_ => panic ! ( ) ,
288
315
}
289
-
290
- }
316
+ }
0 commit comments