1010import static org .opensearch .sql .util .MatcherUtils .rows ;
1111
1212import java .io .IOException ;
13+ import java .util .Locale ;
1314import org .json .JSONObject ;
1415import org .junit .jupiter .api .Test ;
1516import org .opensearch .client .Request ;
@@ -24,7 +25,7 @@ public void init() throws Exception {
2425 loadIndex (Index .STATE_COUNTRY );
2526 loadIndex (Index .STATE_COUNTRY_WITH_NULL );
2627 loadIndex (Index .CALCS );
27- loadIndex (Index .NESTED_WITHOUT_ARRAYS );
28+ loadIndex (Index .NESTED_SIMPLE );
2829 loadIndex (Index .BIG5 );
2930 Request request1 =
3031 new Request ("PUT" , "/" + TEST_INDEX_STATE_COUNTRY_WITH_NULL + "/_doc/7?refresh=true" );
@@ -49,13 +50,27 @@ public void testIsNull() throws IOException {
4950 verifySchema (actual , schema ("age" , "int" ));
5051
5152 verifyDataRows (actual , rows (10 ));
53+ }
5254
53- // Test isNull on struct objects
54- actual = executeQuery ("source=big5 | where isnull(aws) | fields aws" );
55+ @ Test
56+ public void testIsNullWithStruct () throws IOException {
57+ JSONObject actual = executeQuery ("source=big5 | where isnull(aws) | fields aws" );
5558 verifySchema (actual , schema ("aws" , "struct" ));
5659 verifyNumOfRows (actual , 0 );
5760 }
5861
62+ @ Test
63+ public void testIsNullWithNested () throws IOException {
64+ JSONObject actual =
65+ executeQuery (
66+ String .format (
67+ Locale .ROOT ,
68+ "source=%s | where isnull(address) | fields address" ,
69+ TEST_INDEX_NESTED_SIMPLE ));
70+ verifySchema (actual , schema ("address" , "array" ));
71+ verifyNumOfRows (actual , 0 );
72+ }
73+
5974 @ Test
6075 public void testIsNotNull () throws IOException {
6176 JSONObject actual =
@@ -75,13 +90,27 @@ public void testIsNotNull() throws IOException {
7590 rows ("Kevin" ),
7691 rows (" " ),
7792 rows ("" ));
93+ }
7894
79- // Test isNotNull on struct objects
80- actual = executeQuery ("source=big5 | where isnotnull(aws) | fields aws" );
95+ @ Test
96+ public void testIsNotNullWithStruct () throws IOException {
97+ JSONObject actual = executeQuery ("source=big5 | where isnotnull(aws) | fields aws" );
8198 verifySchema (actual , schema ("aws" , "struct" ));
8299 verifyNumOfRows (actual , 1 );
83100 }
84101
102+ @ Test
103+ public void testIsNotNullWithNested () throws IOException {
104+ JSONObject actual =
105+ executeQuery (
106+ String .format (
107+ Locale .ROOT ,
108+ "source=%s | where isnotnull(address) | fields address" ,
109+ TEST_INDEX_NESTED_SIMPLE ));
110+ verifySchema (actual , schema ("address" , "array" ));
111+ verifyNumOfRows (actual , 5 );
112+ }
113+
85114 @ Test
86115 public void testNullIf () throws IOException {
87116 JSONObject actual =
0 commit comments