Vladsz83 commented on code in PR #9987:
URL: https://github.com/apache/ignite/pull/9987#discussion_r861728115
##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/LimitOffsetPlannerTest.java:
##########
@@ -82,86 +84,121 @@ public void testOrderOfRels() throws Exception {
IgniteSchema publicSchema =
createSchemaWithTable(IgniteDistributions.random());
// Simple case, Limit can't be pushed down under Exchange or Sort.
Sort before Exchange is more preferable.
- assertPlan("SELECT * FROM TEST ORDER BY ID LIMIT 10 OFFSET 10",
publicSchema,
+ assertPlan("SELECT * FROM TEST ORDER BY ID LIMIT 5 OFFSET 10",
publicSchema,
+ isInstanceOf(IgniteLimit.class)
+ .and(input(isInstanceOf(IgniteExchange.class)
+ .and(input(isInstanceOf(IgniteSort.class)
+ .and(s -> doubleFromRex(s.fetch, -1) == 5.0)
+ .and(s -> doubleFromRex(s.offset, -1) == 10.0))))));
+
+ // Same simple case but witout offset.
+ assertPlan("SELECT * FROM TEST ORDER BY ID LIMIT 5", publicSchema,
+ isInstanceOf(IgniteLimit.class)
+ .and(input(isInstanceOf(IgniteExchange.class)
+ .and(input(isInstanceOf(IgniteSort.class)
+ .and(s -> doubleFromRex(s.fetch, -1) == 5.0)
+ .and(s -> s.offset == null))))));
+
+ // No special liited sort required if LIMIT is not set.
+ assertPlan("SELECT * FROM TEST ORDER BY ID OFFSET 10", publicSchema,
isInstanceOf(IgniteLimit.class)
.and(input(isInstanceOf(IgniteExchange.class)
- .and(input(isInstanceOf(IgniteSort.class))))));
+ .and(input(isInstanceOf(IgniteSort.class)
+ .and(s -> s.fetch == null)
+ .and(s -> s.offset == null))))));
// Simple case without ordering.
- assertPlan("SELECT * FROM TEST OFFSET 10 ROWS FETCH FIRST 10 ROWS
ONLY", publicSchema,
+ assertPlan("SELECT * FROM TEST OFFSET 10 ROWS FETCH FIRST 5 ROWS
ONLY", publicSchema,
isInstanceOf(IgniteLimit.class)
.and(input(isInstanceOf(IgniteExchange.class)))
- .and(hasChildThat(isInstanceOf(IgniteSort.class)).negate()));
+ .and(hasChildThat(isInstanceOf(IgniteSort.class)
+ .and(s -> doubleFromRex(s.fetch, -1) == 5.0)
+ .and(s -> doubleFromRex(s.offset, -1) ==
10.0)).negate()));
// Check that Sort node is not eliminated by aggregation and Exchange
node is not eliminated by distribution
// required by parent nodes.
assertPlan("SELECT * FROM TEST UNION (SELECT * FROM TEST ORDER BY ID
LIMIT 10)", publicSchema,
nodeOrAnyChild(isInstanceOf(IgniteUnionAll.class)
.and(hasChildThat(isInstanceOf(IgniteLimit.class)
.and(input(isInstanceOf(IgniteExchange.class)
- .and(input(isInstanceOf(IgniteSort.class)))))))));
+ .and(input(isInstanceOf(IgniteSort.class)
+ .and(s -> doubleFromRex(s.fetch, -1) ==
10.0)))))))));
// Check that internal Sort node is not eliminated by external Sort
node with different collation.
assertPlan("SELECT * FROM (SELECT * FROM TEST ORDER BY ID LIMIT 10)
ORDER BY VAL", publicSchema,
nodeOrAnyChild(isInstanceOf(IgniteSort.class)
.and(hasChildThat(isInstanceOf(IgniteLimit.class)
.and(input(isInstanceOf(IgniteExchange.class)
- .and(input(isInstanceOf(IgniteSort.class)))))))));
+ .and(input(isInstanceOf(IgniteSort.class)
+ .and(s -> doubleFromRex(s.fetch, -1) ==
10.0)))))))));
- // Check that extended collation is passed through the Limit node if
it satisfies the Limit collation.
+// // Check that extended collation is passed through the Limit node if
it satisfies the Limit collation.
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]