@@ -68,7 +68,7 @@ async fn test_json_get_union() {
68
68
"| object_foo | {str=abc} |" ,
69
69
"| object_foo_array | {array=[1]} |" ,
70
70
"| object_foo_obj | {object={}} |" ,
71
- "| object_foo_null | {null=true} |" ,
71
+ "| object_foo_null | {null=} |" ,
72
72
"| object_bar | {null=} |" ,
73
73
"| list_foo | {null=} |" ,
74
74
"| invalid_json | {null=} |" ,
@@ -675,7 +675,7 @@ async fn test_json_get_union_array_nested() {
675
675
"+-------------+" ,
676
676
"| {array=[0]} |" ,
677
677
"| {null=} |" ,
678
- "| {null=true} |" ,
678
+ "| {null=} |" ,
679
679
"+-------------+" ,
680
680
] ;
681
681
@@ -725,7 +725,7 @@ async fn test_arrow() {
725
725
"| object_foo | {str=abc} |" ,
726
726
"| object_foo_array | {array=[1]} |" ,
727
727
"| object_foo_obj | {object={}} |" ,
728
- "| object_foo_null | {null=true} |" ,
728
+ "| object_foo_null | {null=} |" ,
729
729
"| object_bar | {null=} |" ,
730
730
"| list_foo | {null=} |" ,
731
731
"| invalid_json | {null=} |" ,
@@ -903,7 +903,7 @@ async fn test_arrow_nested_columns() {
903
903
"+-------------+" ,
904
904
"| {array=[0]} |" ,
905
905
"| {null=} |" ,
906
- "| {null=true} |" ,
906
+ "| {null=} |" ,
907
907
"+-------------+" ,
908
908
] ;
909
909
@@ -990,3 +990,112 @@ async fn test_question_filter() {
990
990
] ;
991
991
assert_batches_eq ! ( expected, & batches) ;
992
992
}
993
+
994
+ #[ tokio:: test]
995
+ async fn test_json_get_union_is_null ( ) {
996
+ let batches = run_query ( "select name, json_get(json_data, 'foo') is null from test" )
997
+ . await
998
+ . unwrap ( ) ;
999
+
1000
+ let expected = [
1001
+ "+------------------+----------------------------------------------+" ,
1002
+ "| name | json_get(test.json_data,Utf8(\" foo\" )) IS NULL |" ,
1003
+ "+------------------+----------------------------------------------+" ,
1004
+ "| object_foo | false |" ,
1005
+ "| object_foo_array | false |" ,
1006
+ "| object_foo_obj | false |" ,
1007
+ "| object_foo_null | true |" ,
1008
+ "| object_bar | true |" ,
1009
+ "| list_foo | true |" ,
1010
+ "| invalid_json | true |" ,
1011
+ "+------------------+----------------------------------------------+" ,
1012
+ ] ;
1013
+ assert_batches_eq ! ( expected, & batches) ;
1014
+ }
1015
+
1016
+ #[ tokio:: test]
1017
+ async fn test_json_get_union_is_not_null ( ) {
1018
+ let batches = run_query ( "select name, json_get(json_data, 'foo') is not null from test" )
1019
+ . await
1020
+ . unwrap ( ) ;
1021
+
1022
+ let expected = [
1023
+ "+------------------+--------------------------------------------------+" ,
1024
+ "| name | json_get(test.json_data,Utf8(\" foo\" )) IS NOT NULL |" ,
1025
+ "+------------------+--------------------------------------------------+" ,
1026
+ "| object_foo | true |" ,
1027
+ "| object_foo_array | true |" ,
1028
+ "| object_foo_obj | true |" ,
1029
+ "| object_foo_null | false |" ,
1030
+ "| object_bar | false |" ,
1031
+ "| list_foo | false |" ,
1032
+ "| invalid_json | false |" ,
1033
+ "+------------------+--------------------------------------------------+" ,
1034
+ ] ;
1035
+ assert_batches_eq ! ( expected, & batches) ;
1036
+ }
1037
+
1038
+ #[ tokio:: test]
1039
+ async fn test_arrow_union_is_null ( ) {
1040
+ let batches = run_query ( "select name, (json_data->'foo') is null from test" )
1041
+ . await
1042
+ . unwrap ( ) ;
1043
+
1044
+ let expected = [
1045
+ "+------------------+----------------------------------+" ,
1046
+ "| name | json_data -> Utf8(\" foo\" ) IS NULL |" ,
1047
+ "+------------------+----------------------------------+" ,
1048
+ "| object_foo | false |" ,
1049
+ "| object_foo_array | false |" ,
1050
+ "| object_foo_obj | false |" ,
1051
+ "| object_foo_null | true |" ,
1052
+ "| object_bar | true |" ,
1053
+ "| list_foo | true |" ,
1054
+ "| invalid_json | true |" ,
1055
+ "+------------------+----------------------------------+" ,
1056
+ ] ;
1057
+ assert_batches_eq ! ( expected, & batches) ;
1058
+ }
1059
+
1060
+ #[ tokio:: test]
1061
+ async fn test_arrow_union_is_not_null ( ) {
1062
+ let batches = run_query ( "select name, (json_data->'foo') is not null from test" )
1063
+ . await
1064
+ . unwrap ( ) ;
1065
+
1066
+ let expected = [
1067
+ "+------------------+--------------------------------------+" ,
1068
+ "| name | json_data -> Utf8(\" foo\" ) IS NOT NULL |" ,
1069
+ "+------------------+--------------------------------------+" ,
1070
+ "| object_foo | true |" ,
1071
+ "| object_foo_array | true |" ,
1072
+ "| object_foo_obj | true |" ,
1073
+ "| object_foo_null | false |" ,
1074
+ "| object_bar | false |" ,
1075
+ "| list_foo | false |" ,
1076
+ "| invalid_json | false |" ,
1077
+ "+------------------+--------------------------------------+" ,
1078
+ ] ;
1079
+ assert_batches_eq ! ( expected, & batches) ;
1080
+ }
1081
+
1082
+ #[ tokio:: test]
1083
+ async fn test_arrow_scalar_union_is_null ( ) {
1084
+ let batches = run_query (
1085
+ r#"
1086
+ select ('{"x": 1}'->'foo') is null as not_contains,
1087
+ ('{"foo": 1}'->'foo') is null as contains_num,
1088
+ ('{"foo": null}'->'foo') is null as contains_null"# ,
1089
+ )
1090
+ . await
1091
+ . unwrap ( ) ;
1092
+
1093
+ let expected = [
1094
+ "+--------------+--------------+---------------+" ,
1095
+ "| not_contains | contains_num | contains_null |" ,
1096
+ "+--------------+--------------+---------------+" ,
1097
+ "| true | false | true |" ,
1098
+ "+--------------+--------------+---------------+" ,
1099
+ ] ;
1100
+ assert_batches_eq ! ( expected, & batches) ;
1101
+ }
0 commit comments