Skip to content

Commit 0d299b5

Browse files
committed
Merge remote-tracking branch 'origin/main' into issues/4636
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
2 parents 199546a + 4b785b0 commit 0d299b5

3 files changed

Lines changed: 71 additions & 75 deletions

File tree

docs/dev/ppl-commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ If you are working on contributing a new PPL command, please read this guide and
5252
- Add a test in `PPLQueryDataAnonymizerTest`
5353

5454
- [ ] **Cross-cluster Tests (optional, nice to have):**
55-
- Add a test in `CrossClusterSearchIT`
55+
- Add a test in `CrossClusterSearchIT`, or in `CalciteCrossClusterSearchIT` if the command requires Calcite.
5656

5757
- [ ] **User doc:**
5858
- Add a xxx.md under `docs/user/ppl/cmd` and link the new doc to `docs/user/ppl/index.md`

integ-test/src/test/java/org/opensearch/sql/security/CalciteCrossClusterSearchIT.java

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,4 +349,74 @@ public void testCrossClusterRexWithOffsetField() throws IOException {
349349
verifyDataRows(
350350
result, rows("Duke Willmington", "u", "vowel=1-1"), rows("Bond", "o", "vowel=1-1"));
351351
}
352+
353+
@Test
354+
public void testCrossClusterAddTotals() throws IOException {
355+
JSONObject result =
356+
executeQuery(
357+
String.format(
358+
"search source=%s| sort 1 age | fields firstname, age | addtotals age",
359+
TEST_INDEX_BANK_REMOTE));
360+
verifyDataRows(result, rows("Nanette", 28, 28));
361+
}
362+
363+
/** CrossClusterSearchIT Test for addcoltotals. */
364+
@Test
365+
public void testCrossClusterAddColTotals() throws IOException {
366+
JSONObject result =
367+
executeQuery(
368+
String.format(
369+
"search source=%s | where firstname='Hattie' or firstname ='Nanette'|fields"
370+
+ " firstname,age,balance | addcoltotals age balance",
371+
TEST_INDEX_BANK_REMOTE));
372+
verifyDataRows(
373+
result, rows("Hattie", 36, 5686), rows("Nanette", 28, 32838), rows(null, 64, 38524));
374+
}
375+
376+
@Test
377+
public void testCrossClusterTranspose() throws IOException {
378+
JSONObject result =
379+
executeQuery(
380+
String.format(
381+
"search source=%s | where firstname='Hattie' or firstname ='Nanette' or"
382+
+ " firstname='Dale'|sort firstname desc |fields firstname,age,balance |"
383+
+ " transpose 3 column_name='column_names'",
384+
TEST_INDEX_BANK_REMOTE));
385+
386+
verifyDataRows(
387+
result,
388+
rows("firstname", "Nanette", "Hattie", "Dale"),
389+
rows("balance", "32838", "5686", "4180"),
390+
rows("age", "28", "36", "33"));
391+
}
392+
393+
@Test
394+
public void testCrossClusterAppend() throws IOException {
395+
JSONObject result =
396+
executeQuery(
397+
String.format(
398+
"search source=%s | stats count() as cnt by gender | append [ search source=%s |"
399+
+ " stats count() as cnt ]",
400+
TEST_INDEX_BANK_REMOTE, TEST_INDEX_BANK_REMOTE));
401+
verifyDataRows(result, rows(3, "F"), rows(4, "M"), rows(7, null));
402+
}
403+
404+
/** CrossClusterSearchIT Test for mvcombine. */
405+
@Test
406+
public void testCrossClusterMvcombine() throws IOException {
407+
408+
JSONObject result =
409+
executeQuery(
410+
String.format(
411+
"search source=%s | where firstname='Hattie' or firstname='Nanette' "
412+
+ "| fields firstname, age | mvcombine age",
413+
TEST_INDEX_BANK_REMOTE));
414+
415+
verifyColumn(result, columnName("firstname"), columnName("age"));
416+
417+
verifyDataRows(
418+
result,
419+
rows("Hattie", new org.json.JSONArray().put(36)),
420+
rows("Nanette", new org.json.JSONArray().put(28)));
421+
}
352422
}

integ-test/src/test/java/org/opensearch/sql/security/CrossClusterSearchIT.java

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -246,78 +246,4 @@ public void testCrossClusterQueryStringWithoutFields() throws IOException {
246246
TEST_INDEX_BANK_REMOTE));
247247
verifyDataRows(result, rows("Hattie"));
248248
}
249-
250-
@Test
251-
public void testCrossClusterAddTotals() throws IOException {
252-
// Test query_string without fields parameter on remote cluster
253-
JSONObject result =
254-
executeQuery(
255-
String.format(
256-
"search source=%s| sort 1 age | fields firstname, age | addtotals age",
257-
TEST_INDEX_BANK_REMOTE));
258-
verifyDataRows(result, rows("Nanette", 28, 28));
259-
}
260-
261-
/** CrossClusterSearchIT Test for addcoltotals. */
262-
@Test
263-
public void testCrossClusterAddColTotals() throws IOException {
264-
// Test query_string without fields parameter on remote cluster
265-
JSONObject result =
266-
executeQuery(
267-
String.format(
268-
"search source=%s | where firstname='Hattie' or firstname ='Nanette'|fields"
269-
+ " firstname,age,balance | addcoltotals age balance",
270-
TEST_INDEX_BANK_REMOTE));
271-
verifyDataRows(
272-
result, rows("Hattie", 36, 5686), rows("Nanette", 28, 32838), rows(null, 64, 38524));
273-
}
274-
275-
@Test
276-
public void testCrossClusterTranspose() throws IOException {
277-
// Test query_string without fields parameter on remote cluster
278-
JSONObject result =
279-
executeQuery(
280-
String.format(
281-
"search source=%s | where firstname='Hattie' or firstname ='Nanette' or"
282-
+ " firstname='Dale'|sort firstname desc |fields firstname,age,balance |"
283-
+ " transpose 3 column_name='column_names'",
284-
TEST_INDEX_BANK_REMOTE));
285-
286-
verifyDataRows(
287-
result,
288-
rows("firstname", "Nanette", "Hattie", "Dale"),
289-
rows("balance", "32838", "5686", "4180"),
290-
rows("age", "28", "36", "33"));
291-
}
292-
293-
@Test
294-
public void testCrossClusterAppend() throws IOException {
295-
// TODO: We should enable calcite by default in CrossClusterSearchIT?
296-
JSONObject result =
297-
executeQuery(
298-
String.format(
299-
"search source=%s | stats count() as cnt by gender | append [ search source=%s |"
300-
+ " stats count() as cnt ]",
301-
TEST_INDEX_BANK_REMOTE, TEST_INDEX_BANK_REMOTE));
302-
verifyDataRows(result, rows(3, "F"), rows(4, "M"), rows(7, null));
303-
}
304-
305-
/** CrossClusterSearchIT Test for mvcombine. */
306-
@Test
307-
public void testCrossClusterMvcombine() throws IOException {
308-
309-
JSONObject result =
310-
executeQuery(
311-
String.format(
312-
"search source=%s | where firstname='Hattie' or firstname='Nanette' "
313-
+ "| fields firstname, age | mvcombine age",
314-
TEST_INDEX_BANK_REMOTE));
315-
316-
verifyColumn(result, columnName("firstname"), columnName("age"));
317-
318-
verifyDataRows(
319-
result,
320-
rows("Hattie", new org.json.JSONArray().put(36)),
321-
rows("Nanette", new org.json.JSONArray().put(28)));
322-
}
323249
}

0 commit comments

Comments
 (0)