Skip to content

Commit bce9661

Browse files
committed
Test explain search without pushdown
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent e7182bc commit bce9661

5 files changed

Lines changed: 22 additions & 7 deletions

File tree

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ public void supportSearchSargPushDown_singleRange() throws IOException {
3030
String query =
3131
"source=opensearch-sql_test_index_account | where age >= 1.0 and age < 10 | fields age";
3232
var result = explainQueryToString(query);
33-
String expected =
34-
loadFromFile("expectedOutput/calcite/explain_sarg_filter_push_single_range.json");
33+
String expected = loadExpectedPlan("explain_sarg_filter_push_single_range.json");
3534
assertJsonEqualsIgnoreId(expected, result);
3635
}
3736

@@ -42,16 +41,14 @@ public void supportSearchSargPushDown_multiRange() throws IOException {
4241
"source=opensearch-sql_test_index_account | where (age > 20 and age < 28) or (age > 25 and"
4342
+ " age < 30) or (age >= 1 and age <= 10) or age = 0 | fields age";
4443
var result = explainQueryToString(query);
45-
String expected =
46-
loadFromFile("expectedOutput/calcite/explain_sarg_filter_push_multi_range.json");
44+
String expected = loadExpectedPlan("explain_sarg_filter_push_multi_range.json");
4745
assertJsonEqualsIgnoreId(expected, result);
4846
}
4947

5048
// Only for Calcite
5149
@Test
5250
public void supportSearchSargPushDown_timeRange() throws IOException {
53-
String expected =
54-
loadFromFile("expectedOutput/calcite/explain_sarg_filter_push_time_range.json");
51+
String expected = loadExpectedPlan("explain_sarg_filter_push_time_range.json");
5552
assertJsonEqualsIgnoreId(
5653
expected,
5754
explainQueryToString(

integ-test/src/test/java/org/opensearch/sql/ppl/ExplainIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ public void testMultiFieldsRelevanceQueryFunctionExplain() throws IOException {
426426
+ " default_operator='or', analyzer=english)"));
427427
}
428428

429-
private String loadExpectedPlan(String fileName) throws IOException {
429+
protected String loadExpectedPlan(String fileName) throws IOException {
430430
String prefix;
431431
if (isCalciteEnabled()) {
432432
if (isPushdownEnabled()) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"calcite": {
3+
"logical": "LogicalProject(age=[$8])\n LogicalFilter(condition=[SEARCH($8, Sarg[0, [1..10], (20..30)])])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n",
4+
"physical": "EnumerableCalc(expr#0..16=[{inputs}], expr#17=[Sarg[0, [1..10], (20..30)]], expr#18=[SEARCH($t8, $t17)], age=[$t8], $condition=[$t18])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n"
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"calcite": {
3+
"logical": "LogicalProject(age=[$8])\n LogicalFilter(condition=[SEARCH($8, Sarg[[1.0:DECIMAL(11, 1)..10:DECIMAL(11, 1))]:DECIMAL(11, 1))])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n",
4+
"physical": "EnumerableCalc(expr#0..16=[{inputs}], expr#17=[Sarg[[1.0:DECIMAL(11, 1)..10:DECIMAL(11, 1))]:DECIMAL(11, 1)], expr#18=[SEARCH($t8, $t17)], age=[$t8], $condition=[$t18])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n"
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"calcite": {
3+
"logical": "LogicalProject(account_number=[$0], firstname=[$1], address=[$2], birthdate=[$3], gender=[$4], city=[$5], lastname=[$6], balance=[$7], employer=[$8], state=[$9], age=[$10], email=[$11], male=[$12])\n LogicalFilter(condition=[AND(>=($3, TIMESTAMP('2016-12-08 00:00:00.000000000':VARCHAR)), <($3, TIMESTAMP('2018-11-09 00:00:00.000000000':VARCHAR)))])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_bank]])\n",
4+
"physical": "EnumerableCalc(expr#0..18=[{inputs}], expr#19=[Sarg[['2016-12-08 00:00:00':VARCHAR..'2018-11-09 00:00:00':VARCHAR)]:VARCHAR], expr#20=[SEARCH($t3, $t19)], proj#0..12=[{exprs}], $condition=[$t20])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_bank]])\n"
5+
}
6+
}

0 commit comments

Comments
 (0)