Skip to content

Commit 0ccd9b4

Browse files
committed
add IT in explain
Signed-off-by: xinyual <xinyual@amazon.com>
1 parent f3b53af commit 0ccd9b4

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class ExplainIT extends PPLIntegTestCase {
1919
public void init() throws Exception {
2020
super.init();
2121
loadIndex(Index.ACCOUNT);
22+
loadIndex(Index.BANK);
2223
}
2324

2425
@Test
@@ -57,6 +58,21 @@ public void testFilterPushDownExplain() throws IOException {
5758
+ "| fields age"));
5859
}
5960

61+
@Test
62+
public void testFilterByCompareStringTimestampPushDownExplain() throws IOException {
63+
String expected =
64+
isCalciteEnabled()
65+
? loadFromFile("expectedOutput/calcite/explain_filter_push_compare_timestamp_string.json")
66+
: loadFromFile("expectedOutput/ppl/explain_filter_push_compare_timestamp_string.json");
67+
68+
assertJsonEqualsIgnoreId(
69+
expected,
70+
explainQueryToString(
71+
"source=opensearch-sql_test_index_bank"
72+
+ "| where birthdate > '2016-12-08 00:00:00' "
73+
+ "| where birthdate < '2018-11-09 00:00:00' "));
74+
}
75+
6076
@Test
6177
public void testFilterAndAggPushDownExplain() throws IOException {
6278
String expected =
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('2018-11-09 00:00:00':VARCHAR))])\n LogicalFilter(condition=[>($3, TIMESTAMP('2016-12-08 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, '2016-12-08 00:00:00'), FILTER-><($3, '2018-11-09 00:00:00')], OpenSearchRequestBuilder(sourceBuilder={\"from\":0,\"timeout\":\"1m\",\"query\":{\"bool\":{\"filter\":[{\"range\":{\"birthdate\":{\"from\":\"2016-12-08T00:00:00.000Z\",\"to\":null,\"include_lower\":false,\"include_upper\":true,\"boost\":1.0}}},{\"range\":{\"birthdate\":{\"from\":null,\"to\":\"2018-11-09T00:00:00.000Z\",\"include_lower\":true,\"include_upper\":false,\"boost\":1.0}}}],\"adjust_pure_negative\":true,\"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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"root" : {
3+
"name" : "ProjectOperator",
4+
"description" : {
5+
"fields" : "[account_number, firstname, address, birthdate, gender, city, lastname, balance, employer, state, age, email, male]"
6+
},
7+
"children" : [ {
8+
"name" : "OpenSearchIndexScan",
9+
"description" : {
10+
"request" : "OpenSearchQueryRequest(indexName=opensearch-sql_test_index_bank, sourceBuilder={\"from\":0,\"size\":10000,\"timeout\":\"1m\",\"query\":{\"bool\":{\"filter\":[{\"range\":{\"birthdate\":{\"from\":null,\"to\":1541721600000,\"include_lower\":true,\"include_upper\":false,\"boost\":1.0}}},{\"range\":{\"birthdate\":{\"from\":1481155200000,\"to\":null,\"include_lower\":false,\"include_upper\":true,\"boost\":1.0}}}],\"adjust_pure_negative\":true,\"boost\":1.0}},\"_source\":{\"includes\":[\"account_number\",\"firstname\",\"address\",\"birthdate\",\"gender\",\"city\",\"lastname\",\"balance\",\"employer\",\"state\",\"age\",\"email\",\"male\"],\"excludes\":[]},\"sort\":[{\"_doc\":{\"order\":\"asc\"}}]}, needClean=true, searchDone=false, pitId=s9y3QQEeb3BlbnNlYXJjaC1zcWxfdGVzdF9pbmRleF9iYW5rFmtHVFBVZFdaVEVTdzh4ZFVDYlFiU2cAFk8tSmZBa2hpUXRHOEFVTGdnMmxYUncAAAAAAAAAAAEWOFZwckxjWGhUaXVYRVBRWXptNFlQdwEWa0dUUFVkV1pURVN3OHhkVUNiUWJTZwAA, cursorKeepAlive=1m, searchAfter=null, searchResponse=null)"
11+
},
12+
"children" : [ ]
13+
} ]
14+
}
15+
}

0 commit comments

Comments
 (0)