Skip to content

Commit b469c1c

Browse files
committed
Move Calcite-only tests from CrossClusterSearchIT to CalciteCrossClusterSearchIT (#5085)
* Move tests for calcite-only commands from CrossClusterSearchIT to CalciteCrossClusterSearchIT Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Ask to use CalciteCrossClusterSearchIT when developing calcite-only commands Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> --------- Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> (cherry picked from commit 4b785b0)
1 parent 043e11e commit b469c1c

3 files changed

Lines changed: 71 additions & 79 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 & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -246,82 +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-
try {
253-
enableCalcite();
254-
255-
// Test query_string without fields parameter on remote cluster
256-
JSONObject result =
257-
executeQuery(
258-
String.format(
259-
"search source=%s| sort 1 age | fields firstname, age | addtotals age",
260-
TEST_INDEX_BANK_REMOTE));
261-
verifyDataRows(result, rows("Nanette", 28, 28));
262-
} finally {
263-
disableCalcite();
264-
}
265-
}
266-
267-
/** CrossClusterSearchIT Test for addcoltotals. */
268-
@Test
269-
public void testCrossClusterAddColTotals() throws IOException {
270-
try {
271-
enableCalcite();
272-
273-
// Test query_string without fields parameter on remote cluster
274-
JSONObject result =
275-
executeQuery(
276-
String.format(
277-
"search source=%s | where firstname='Hattie' or firstname ='Nanette'|fields"
278-
+ " firstname,age,balance | addcoltotals age balance",
279-
TEST_INDEX_BANK_REMOTE));
280-
verifyDataRows(
281-
result, rows("Hattie", 36, 5686), rows("Nanette", 28, 32838), rows(null, 64, 38524));
282-
} finally {
283-
disableCalcite();
284-
}
285-
}
286-
287-
@Test
288-
public void testCrossClusterTranspose() throws IOException {
289-
try {
290-
enableCalcite();
291-
292-
// Test query_string without fields parameter on remote cluster
293-
JSONObject result =
294-
executeQuery(
295-
String.format(
296-
"search source=%s | where firstname='Hattie' or firstname ='Nanette' or"
297-
+ " firstname='Dale'|sort firstname desc |fields firstname,age,balance |"
298-
+ " transpose 3 column_name='column_names'",
299-
TEST_INDEX_BANK_REMOTE));
300-
301-
verifyDataRows(
302-
result,
303-
rows("firstname", "Nanette", "Hattie", "Dale"),
304-
rows("balance", "32838", "5686", "4180"),
305-
rows("age", "28", "36", "33"));
306-
} finally {
307-
disableCalcite();
308-
}
309-
}
310-
311-
@Test
312-
public void testCrossClusterAppend() throws IOException {
313-
try {
314-
enableCalcite();
315-
316-
JSONObject result =
317-
executeQuery(
318-
String.format(
319-
"search source=%s | stats count() as cnt by gender | append [ search source=%s |"
320-
+ " stats count() as cnt ]",
321-
TEST_INDEX_BANK_REMOTE, TEST_INDEX_BANK_REMOTE));
322-
verifyDataRows(result, rows(3, "F"), rows(4, "M"), rows(7, null));
323-
} finally {
324-
disableCalcite();
325-
}
326-
}
327249
}

0 commit comments

Comments
 (0)