@@ -880,6 +880,38 @@ async fn test_plan_arrow_double_nested() {
880880 assert_eq ! ( lines, expected) ;
881881}
882882
883+ #[ tokio:: test]
884+ async fn test_double_arrow_double_nested ( ) {
885+ let batches = run_query ( "select name, json_data->>'foo'->>0 from test" ) . await . unwrap ( ) ;
886+
887+ let expected = [
888+ "+------------------+---------------------------------------------+" ,
889+ "| name | test.json_data ->> Utf8(\" foo\" ) ->> Int64(0) |" ,
890+ "+------------------+---------------------------------------------+" ,
891+ "| object_foo | |" ,
892+ "| object_foo_array | 1 |" ,
893+ "| object_foo_obj | |" ,
894+ "| object_foo_null | |" ,
895+ "| object_bar | |" ,
896+ "| list_foo | |" ,
897+ "| invalid_json | |" ,
898+ "+------------------+---------------------------------------------+" ,
899+ ] ;
900+ assert_batches_eq ! ( expected, & batches) ;
901+ }
902+
903+ #[ tokio:: test]
904+ async fn test_plan_double_arrow_double_nested ( ) {
905+ let lines = logical_plan ( r"explain select json_data->>'foo'->>0 from test" ) . await ;
906+
907+ let expected = [
908+ "Projection: json_as_text(test.json_data, Utf8(\" foo\" ), Int64(0)) AS test.json_data ->> Utf8(\" foo\" ) ->> Int64(0)" ,
909+ " TableScan: test projection=[json_data]" ,
910+ ] ;
911+
912+ assert_eq ! ( lines, expected) ;
913+ }
914+
883915#[ tokio:: test]
884916async fn test_arrow_double_nested_cast ( ) {
885917 let batches = run_query ( "select name, (json_data->'foo'->0)::int from test" )
@@ -914,6 +946,41 @@ async fn test_plan_arrow_double_nested_cast() {
914946 assert_eq ! ( lines, expected) ;
915947}
916948
949+ #[ tokio:: test]
950+ async fn test_double_arrow_double_nested_cast ( ) {
951+ let batches = run_query ( "select name, (json_data->>'foo'->>0)::int from test" )
952+ . await
953+ . unwrap ( ) ;
954+
955+ let expected = [
956+ "+------------------+---------------------------------------------+" ,
957+ "| name | test.json_data ->> Utf8(\" foo\" ) ->> Int64(0) |" ,
958+ "+------------------+---------------------------------------------+" ,
959+ "| object_foo | |" ,
960+ "| object_foo_array | 1 |" ,
961+ "| object_foo_obj | |" ,
962+ "| object_foo_null | |" ,
963+ "| object_bar | |" ,
964+ "| list_foo | |" ,
965+ "| invalid_json | |" ,
966+ "+------------------+---------------------------------------------+" ,
967+ ] ;
968+ assert_batches_eq ! ( expected, & batches) ;
969+ }
970+
971+ #[ tokio:: test]
972+ async fn test_plan_double_arrow_double_nested_cast ( ) {
973+ let lines = logical_plan ( r"explain select (json_data->>'foo'->>0)::int from test" ) . await ;
974+
975+ // NB: json_as_text(..)::int is NOT the same as `json_get_int(..)`, hence the cast is not rewritten
976+ let expected = [
977+ "Projection: CAST(json_as_text(test.json_data, Utf8(\" foo\" ), Int64(0)) AS test.json_data ->> Utf8(\" foo\" ) ->> Int64(0) AS Int32)" ,
978+ " TableScan: test projection=[json_data]" ,
979+ ] ;
980+
981+ assert_eq ! ( lines, expected) ;
982+ }
983+
917984#[ tokio:: test]
918985async fn test_arrow_nested_columns ( ) {
919986 let expected = [
0 commit comments