Skip to content

Commit 98fbb12

Browse files
committed
Make expand empty array IT more specific
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent fe11b61 commit 98fbb12

1 file changed

Lines changed: 8 additions & 101 deletions

File tree

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteExpandCommandIT.java

Lines changed: 8 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -287,113 +287,20 @@ public void testExpandEmptyArray() throws Exception {
287287
client().performRequest(insertRequest);
288288

289289
JSONObject response =
290-
executeQuery(String.format("source=%s | expand address", TEST_INDEX_NESTED_SIMPLE));
290+
executeQuery(
291+
String.format(
292+
"source=%s | where name='ben' | expand address", TEST_INDEX_NESTED_SIMPLE));
291293
verifySchema(
292294
response,
293295
schema("name", "string"),
294296
schema("age", "bigint"),
295297
schema("id", "bigint"),
296-
schema("address", "struct"));
297-
verifyDataRows(
298-
response,
299-
rows(
300-
"abbas",
301-
null,
302-
24,
303-
new JSONObject()
304-
.put("city", "New york city")
305-
.put("state", "NY")
306-
.put("moveInDate", new JSONObject().put("dateAndTime", "1984-04-12 09:07:42"))),
307-
rows(
308-
"abbas",
309-
null,
310-
24,
311-
new JSONObject()
312-
.put("city", "bellevue")
313-
.put("state", "WA")
314-
.put(
315-
"moveInDate",
316-
new JSONArray()
317-
.put(new JSONObject().put("dateAndTime", "2023-05-03 08:07:42"))
318-
.put(new JSONObject().put("dateAndTime", "2001-11-11 04:07:44")))),
319-
rows(
320-
"abbas",
321-
null,
322-
24,
323-
new JSONObject()
324-
.put("city", "seattle")
325-
.put("state", "WA")
326-
.put("moveInDate", new JSONObject().put("dateAndTime", "1966-03-19 03:04:55"))),
327-
rows(
328-
"abbas",
329-
null,
330-
24,
331-
new JSONObject()
332-
.put("city", "chicago")
333-
.put("state", "IL")
334-
.put("moveInDate", new JSONObject().put("dateAndTime", "2011-06-01 01:01:42"))),
335-
rows(
336-
"chen",
337-
null,
338-
32,
339-
new JSONObject()
340-
.put("city", "Miami")
341-
.put("state", "Florida")
342-
.put("moveInDate", new JSONObject().put("dateAndTime", "1901-08-11 04:03:33"))),
343-
rows(
344-
"chen",
345-
null,
346-
32,
347-
new JSONObject()
348-
.put("city", "los angeles")
349-
.put("state", "CA")
350-
.put("moveInDate", new JSONObject().put("dateAndTime", "2023-05-03 08:07:42"))),
351-
rows(
352-
"peng",
353-
null,
354-
26,
355-
new JSONObject()
356-
.put("city", "san diego")
357-
.put("state", "CA")
358-
.put("moveInDate", new JSONObject().put("dateAndTime", "2001-11-11 04:07:44"))),
359-
rows(
360-
"peng",
361-
null,
362-
26,
363-
new JSONObject()
364-
.put("city", "austin")
365-
.put("state", "TX")
366-
.put("moveInDate", new JSONObject().put("dateAndTime", "1977-07-13 09:04:41"))),
367-
rows(
368-
"andy",
369-
4,
370-
19,
371-
new JSONObject()
372-
.put("city", "houston")
373-
.put("state", "TX")
374-
.put("moveInDate", new JSONObject().put("dateAndTime", "1933-12-12 05:05:45"))),
375-
rows(
376-
"david",
377-
null,
378-
25,
379-
new JSONObject()
380-
.put("city", "raleigh")
381-
.put("state", "NC")
382-
.put("moveInDate", new JSONObject().put("dateAndTime", "1909-06-17 01:04:21"))),
383-
rows(
384-
"david",
385-
null,
386-
25,
387-
new JSONObject()
388-
.put("city", "charlotte")
389-
.put("state", "SC")
390-
.put(
391-
"moveInDate",
392-
new JSONArray()
393-
.put(new JSONObject().put("dateAndTime", "2001-11-11 04:07:44")))),
394-
rows("ben", 437821, 47, null));
298+
// The type is inferred at runtime. When the array is empty and is the
299+
// first element of the column, it is set to "undefined".
300+
schema("address", "undefined"));
301+
verifyDataRows(response, rows("ben", 437821, 47, null));
395302

396-
verifyNumOfRows(response, 12);
303+
verifyNumOfRows(response, 1);
397304
Request deleteRequest =
398305
new Request(
399306
"DELETE", String.format("/%s/_doc/%d?refresh=true", TEST_INDEX_NESTED_SIMPLE, docId));

0 commit comments

Comments
 (0)