Skip to content

Commit 9aaaed7

Browse files
committed
fixes
Signed-off-by: Kai Huang <[email protected]>
1 parent ba803dc commit 9aaaed7

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

integ-test/src/test/java/org/opensearch/sql/calcite/CalciteNoPushdownIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
CalciteQueryAnalysisIT.class,
8989
CalciteRareCommandIT.class,
9090
CalciteRegexCommandIT.class,
91+
CalciteReverseCommandIT.class,
9192
CalciteRexCommandIT.class,
9293
CalciteRenameCommandIT.class,
9394
CalciteReplaceCommandIT.class,

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,16 +411,26 @@ public void testFilterWithSearchCall() throws IOException {
411411

412412
@Test
413413
public void testExplainWithReverse() throws IOException {
414-
String result =
415-
executeWithReplace(
416-
"explain source=opensearch-sql_test_index_account | sort age | reverse | head 5");
414+
String query = "source=opensearch-sql_test_index_account | reverse | head 5";
415+
var result = explainQueryToString(query);
416+
String expected = loadExpectedPlan("explain_reverse_fallback.json");
417+
assertJsonEqualsIgnoreId(expected, result);
418+
}
417419

418-
// Verify that the plan contains a LogicalSort with fetch (from head 5)
419-
assertTrue(result.contains("LogicalSort") && result.contains("fetch=[5]"));
420+
@Test
421+
public void testExplainWithReversePushdown() throws IOException {
422+
String query = "source=opensearch-sql_test_index_account | sort - age | reverse";
423+
var result = explainQueryToString(query);
424+
String expected = loadExpectedPlan("explain_reverse_pushdown_single.json");
425+
assertJsonEqualsIgnoreId(expected, result);
426+
}
420427

421-
// Verify that reverse added a ROW_NUMBER and another sort (descending)
422-
assertTrue(result.contains("ROW_NUMBER()"));
423-
assertTrue(result.contains("dir0=[DESC]"));
428+
@Test
429+
public void testExplainWithReversePushdownMultipleFields() throws IOException {
430+
String query = "source=opensearch-sql_test_index_account | sort - age, + firstname | reverse";
431+
var result = explainQueryToString(query);
432+
String expected = loadExpectedPlan("explain_reverse_pushdown_multiple.json");
433+
assertJsonEqualsIgnoreId(expected, result);
424434
}
425435

426436
@Test

0 commit comments

Comments
 (0)