Skip to content

Commit d5a9495

Browse files
committed
Add limit-filter-limit pushdown IT
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 85af924 commit d5a9495

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,20 @@ public void testMultipleLimitExplain() throws Exception {
164164
+ "| head 10 "
165165
+ "| head 5 "
166166
+ "| fields age"));
167+
168+
// TODO: Fix limit-filter-limit pushdown without Calcite
169+
String expected10ThenFilterThen5 =
170+
isCalciteEnabled()
171+
? loadFromFile("expectedOutput/calcite/explain_limit_10_filter_5.json")
172+
: loadFromFile("expectedOutput/ppl/explain_limit_10_filter_5.json");
173+
assertJsonEqualsIgnoreRelId(
174+
expected10ThenFilterThen5,
175+
explainQueryToString(
176+
"source=opensearch-sql_test_index_account"
177+
+ "| head 10 "
178+
+ "| where age > 30 "
179+
+ "| head 5 "
180+
+ "| fields age"));
167181
}
168182

169183
@Test
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 LogicalSort(fetch=[5])\n LogicalFilter(condition=[>($8, 30)])\n LogicalSort(fetch=[10])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n",
4+
"physical": "EnumerableLimit(fetch=[5])\n EnumerableCalc(expr#0=[{inputs}], expr#1=[30], expr#2=[>($t0, $t1)], age=[$t0], $condition=[$t2])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]], PushDownContext=[[LIMIT->10, PROJECT->[age]], OpenSearchRequestBuilder(sourceBuilder={\"from\":0,\"size\":10,\"timeout\":\"1m\",\"_source\":{\"includes\":[\"age\"],\"excludes\":[]}}, requestedTotalSize=10, pageSize=null, startFrom=0)])\n"
5+
}
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"root": {
3+
"name": "ProjectOperator",
4+
"description": {
5+
"fields": "[age]"
6+
},
7+
"children": [
8+
{
9+
"name": "OpenSearchIndexScan",
10+
"description": {
11+
"request": "OpenSearchQueryRequest(indexName=opensearch-sql_test_index_account, sourceBuilder={\"from\":0,\"size\":5,\"timeout\":\"1m\",\"query\":{\"range\":{\"age\":{\"from\":30,\"to\":null,\"include_lower\":false,\"include_upper\":true,\"boost\":1.0}}},\"_source\":{\"includes\":[\"age\"],\"excludes\":[]},\"sort\":[{\"_doc\":{\"order\":\"asc\"}}]}, needClean=true, searchDone=false, pitId=null, cursorKeepAlive=null, searchAfter=null, searchResponse=null)"
12+
},
13+
"children": []
14+
}
15+
]
16+
}
17+
}

0 commit comments

Comments
 (0)