@@ -973,70 +973,15 @@ public void testTopNPushdownDisabled()
973
973
}
974
974
975
975
@ Test
976
+ @ Override
976
977
public void testTopNPushdown ()
977
978
{
979
+ super .testTopNPushdown ();
980
+
978
981
if (!hasBehavior (SUPPORTS_TOPN_PUSHDOWN )) {
979
- assertThat (query ("SELECT orderkey FROM orders ORDER BY orderkey LIMIT 10" ))
980
- .ordered ()
981
- .isNotFullyPushedDown (TopNNode .class );
982
982
return ;
983
983
}
984
984
985
- assertThat (query ("SELECT orderkey FROM orders ORDER BY orderkey LIMIT 10" ))
986
- .ordered ()
987
- .isFullyPushedDown ();
988
-
989
- assertThat (query ("SELECT orderkey FROM orders ORDER BY orderkey DESC LIMIT 10" ))
990
- .ordered ()
991
- .isFullyPushedDown ();
992
-
993
- // multiple sort columns with different orders
994
- assertThat (query ("SELECT * FROM orders ORDER BY shippriority DESC, totalprice ASC LIMIT 10" ))
995
- .ordered ()
996
- .isFullyPushedDown ();
997
-
998
- // TopN over aggregation column
999
- if (hasBehavior (SUPPORTS_AGGREGATION_PUSHDOWN )) {
1000
- assertThat (query ("SELECT sum(totalprice) AS total FROM orders GROUP BY custkey ORDER BY total DESC LIMIT 10" ))
1001
- .ordered ()
1002
- .isFullyPushedDown ();
1003
- }
1004
-
1005
- // TopN over TopN
1006
- assertThat (query ("SELECT orderkey, totalprice FROM (SELECT orderkey, totalprice FROM orders ORDER BY 1, 2 LIMIT 10) ORDER BY 2, 1 LIMIT 5" ))
1007
- .ordered ()
1008
- .isFullyPushedDown ();
1009
-
1010
- assertThat (query ("" +
1011
- "SELECT orderkey, totalprice " +
1012
- "FROM (SELECT orderkey, totalprice FROM (SELECT orderkey, totalprice FROM orders ORDER BY 1, 2 LIMIT 10) " +
1013
- "ORDER BY 2, 1 LIMIT 5) ORDER BY 1, 2 LIMIT 3" ))
1014
- .ordered ()
1015
- .isFullyPushedDown ();
1016
-
1017
- // TopN over limit - use high limit for deterministic result
1018
- assertThat (query ("SELECT orderkey, totalprice FROM (SELECT orderkey, totalprice FROM orders LIMIT 15000) ORDER BY totalprice ASC LIMIT 5" ))
1019
- .ordered ()
1020
- .isFullyPushedDown ();
1021
-
1022
- // TopN over limit with filter
1023
- assertThat (query ("" +
1024
- "SELECT orderkey, totalprice " +
1025
- "FROM (SELECT orderkey, totalprice FROM orders WHERE orderdate = DATE '1995-09-16' LIMIT 20) " +
1026
- "ORDER BY totalprice ASC LIMIT 5" ))
1027
- .ordered ()
1028
- .isFullyPushedDown ();
1029
-
1030
- // TopN over aggregation with filter
1031
- if (hasBehavior (SUPPORTS_AGGREGATION_PUSHDOWN )) {
1032
- assertThat (query ("" +
1033
- "SELECT * " +
1034
- "FROM (SELECT SUM(totalprice) as sum, custkey AS total FROM orders GROUP BY custkey HAVING COUNT(*) > 3) " +
1035
- "ORDER BY sum DESC LIMIT 10" ))
1036
- .ordered ()
1037
- .isFullyPushedDown ();
1038
- }
1039
-
1040
985
// TopN over LEFT join (enforces SINGLE TopN cannot be pushed below OUTER side of join)
1041
986
// We expect PARTIAL TopN on the LEFT side of join to be pushed down.
1042
987
assertThat (query (
0 commit comments