Skip to content

Commit f3b53af

Browse files
committed
add IT
Signed-off-by: xinyual <xinyual@amazon.com>
1 parent 074db3d commit f3b53af

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.io.IOException;
1111
import org.junit.jupiter.api.Test;
1212
import org.opensearch.client.Request;
13+
import org.opensearch.sql.legacy.TestsConstants;
1314
import org.opensearch.sql.ppl.PPLIntegTestCase;
1415

1516
public class CalcitePPLExplainIT extends PPLIntegTestCase {
@@ -30,6 +31,7 @@ public void init() throws Exception {
3031
Request request3 = new Request("PUT", "/test1/_doc/1?refresh=true");
3132
request3.setJsonEntity("{\"name\": \"HELLO\", \"alias\": \"Hello\"}");
3233
client().performRequest(request3);
34+
loadIndex(Index.BANK);
3335
}
3436

3537
@Test
@@ -53,6 +55,23 @@ public void testExplainCommandExtended() throws IOException {
5355
+ " org.apache.calcite.DataContext root)"));
5456
}
5557

58+
@Test
59+
public void testFilterPushdown() throws IOException {
60+
var result =
61+
explainQueryToString(
62+
String.format(
63+
"source=%s | where birthdate < '2017-11-20 00:00:00'",
64+
TestsConstants.TEST_INDEX_BANK));
65+
String expected =
66+
isPushdownEnabled()
67+
? loadFromFile(
68+
"expectedOutput/calcite/explain_filter_compare_string_timestamp_w_pushdown.json")
69+
: loadFromFile(
70+
"expectedOutput/calcite/explain_filter_compare_string_timestamp_wo_pushdown.json");
71+
72+
assertJsonEquals(expected, result);
73+
}
74+
5675
@Test
5776
public void testExplainCommandCost() throws IOException {
5877
var result = executeWithReplace("explain cost source=test | where age = 20 | fields name, age");
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=[<($3, TIMESTAMP('2017-11-20 00:00:00':VARCHAR))])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_bank]])\n",
4+
"physical" : "CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_bank]], PushDownContext=[[PROJECT->[account_number, firstname, address, birthdate, gender, city, lastname, balance, employer, state, age, email, male], FILTER-><($3, '2017-11-20 00:00:00')], OpenSearchRequestBuilder(sourceBuilder={\"from\":0,\"timeout\":\"1m\",\"query\":{\"range\":{\"birthdate\":{\"from\":null,\"to\":\"2017-11-20T00:00:00.000Z\",\"include_lower\":true,\"include_upper\":false,\"boost\":1.0}}},\"_source\":{\"includes\":[\"account_number\",\"firstname\",\"address\",\"birthdate\",\"gender\",\"city\",\"lastname\",\"balance\",\"employer\",\"state\",\"age\",\"email\",\"male\"],\"excludes\":[]},\"sort\":[{\"_doc\":{\"order\":\"asc\"}}]}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])\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=[<($3, TIMESTAMP('2017-11-20 00:00:00':VARCHAR))])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_bank]])\n",
4+
"physical": "EnumerableCalc(expr#0..18=[{inputs}], expr#19=['2017-11-20 00:00:00':EXPR_TIMESTAMP VARCHAR], expr#20=[<($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)