@@ -206,15 +206,20 @@ fn test_redshift_json_path() {
206206 let select = redshift ( ) . verified_only_select ( sql) ;
207207
208208 assert_eq ! (
209- & Expr :: JsonAccess {
209+ & Expr :: JsonAccess {
210210 value: Box :: new( Expr :: CompoundIdentifier ( vec![
211211 Ident :: new( "cust" ) ,
212212 Ident :: new( "c_orders" )
213213 ] ) ) ,
214- path: JsonPath {
214+ path: JsonPath {
215215 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+ }
218223 ]
219224 }
220225 } ,
@@ -224,15 +229,19 @@ fn test_redshift_json_path() {
224229 let sql = "SELECT cust.c_orders[0]['id'] FROM customer_orders_lineitem" ;
225230 let select = redshift ( ) . verified_only_select ( sql) ;
226231 assert_eq ! (
227- & Expr :: JsonAccess {
232+ & Expr :: JsonAccess {
228233 value: Box :: new( Expr :: CompoundIdentifier ( vec![
229234 Ident :: new( "cust" ) ,
230235 Ident :: new( "c_orders" )
231236 ] ) ) ,
232- path: JsonPath {
237+ path: JsonPath {
233238 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+ }
236245 ]
237246 }
238247 } ,
@@ -248,10 +257,15 @@ fn test_parse_json_path_from() {
248257 assert_eq ! ( name, & ObjectName ( vec![ Ident :: new( "src" ) ] ) ) ;
249258 assert_eq ! (
250259 partiql,
251- & Some ( JsonPath {
260+ & Some ( JsonPath {
252261 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+ }
255269 ]
256270 } )
257271 ) ;
@@ -265,12 +279,22 @@ fn test_parse_json_path_from() {
265279 assert_eq ! ( name, & ObjectName ( vec![ Ident :: new( "src" ) ] ) ) ;
266280 assert_eq ! (
267281 partiql,
268- & Some ( JsonPath {
282+ & Some ( JsonPath {
269283 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+ } ,
274298 ]
275299 } )
276300 ) ;
@@ -281,10 +305,12 @@ fn test_parse_json_path_from() {
281305 let select = redshift ( ) . verified_only_select ( "SELECT * FROM src.a.b" ) ;
282306 match & select. from [ 0 ] . relation {
283307 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+ ) ;
285312 assert_eq ! ( partiql, & None ) ;
286313 }
287314 _ => panic ! ( ) ,
288315 }
289-
290- }
316+ }
0 commit comments