Skip to content

Commit 6eba1f7

Browse files
pramodsatyaaditi-pandit
authored andcommitted
[native] Add e2e tests for aggregate window functions
1 parent 24f1c14 commit 6eba1f7

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

‎presto-native-execution/src/test/java/com/facebook/presto/nativeworker/AbstractTestNativeWindowQueries.java‎

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public abstract class AbstractTestNativeWindowQueries
2828
extends AbstractTestQueryFramework
2929
{
3030
protected enum FunctionType {
31-
RANK, VALUE,
31+
RANK, VALUE, AGGREGATE,
3232
}
3333

3434
@Override
@@ -74,7 +74,7 @@ protected List<String> getQueries(String function, FunctionType functionType)
7474
ImmutableList.Builder<String> queries = ImmutableList.builder();
7575
List<String> overClauses = new ArrayList<>(OVER_CLAUSES_WITH_ORDER_BY);
7676
List<String> frameClauses = FRAME_CLAUSES;
77-
if (functionType == FunctionType.VALUE) {
77+
if (functionType != FunctionType.RANK) {
7878
overClauses.addAll(OVER_CLAUSES_WITHOUT_ORDER_BY);
7979
}
8080
List<String> windowClauseList = new ArrayList<>();
@@ -115,6 +115,12 @@ protected void testWindowFunction(String functionName, FunctionType functionType
115115
}
116116
}
117117

118+
protected void testWindowAggregate(String functionName)
119+
{
120+
testWindowFunction(functionName + "(orderkey)", FunctionType.AGGREGATE);
121+
testWindowFunction(functionName + "(totalprice)", FunctionType.AGGREGATE);
122+
}
123+
118124
@Test
119125
public void testCumeDist()
120126
{
@@ -197,4 +203,34 @@ public void testOverlappingPartitionAndSortingKeys()
197203
assertQuery("SELECT min(orderkey) OVER (PARTITION BY orderdate ORDER BY orderdate, totalprice) FROM orders");
198204
assertQuery("SELECT * FROM (SELECT row_number() over(partition by orderstatus order by orderkey, orderstatus) rn, * from orders) WHERE rn = 1");
199205
}
206+
207+
@Test
208+
public void testSum()
209+
{
210+
testWindowAggregate("sum");
211+
}
212+
213+
@Test
214+
public void testAvg()
215+
{
216+
testWindowAggregate("avg");
217+
}
218+
219+
@Test
220+
public void testCount()
221+
{
222+
testWindowAggregate("count");
223+
}
224+
225+
@Test
226+
public void testMin()
227+
{
228+
testWindowAggregate("min");
229+
}
230+
231+
@Test
232+
public void testMax()
233+
{
234+
testWindowAggregate("max");
235+
}
200236
}

0 commit comments

Comments
 (0)