ygerzhedovich commented on code in PR #1629:
URL: https://github.com/apache/ignite-3/pull/1629#discussion_r1114081976


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/rule/SortConverterRule.java:
##########
@@ -68,21 +70,34 @@ public void onMatch(RelOptRuleCall call) {
                     .replace(sort.getCollation())
                     .replace(IgniteDistributions.single());
 
-            call.transformTo(
-                    new IgniteLimit(
-                            cluster,
-                            traits,
-                            convert(sort.getInput(), traits),
-                            sort.offset,
-                            sort.fetch
-                    )
-            );
+            if (sort.collation == RelCollations.EMPTY || sort.fetch == null) {
+                call.transformTo(new IgniteLimit(cluster, traits, 
convert(sort.getInput(), traits), sort.offset,
+                        sort.fetch));
+            } else {
+                RelNode igniteSort = new IgniteSort(
+                        cluster,
+                        
cluster.traitSetOf(IgniteConvention.INSTANCE).replace(sort.getCollation()),
+                        convert(sort.getInput(), 
cluster.traitSetOf(IgniteConvention.INSTANCE)),
+                        sort.getCollation(),
+                        sort.offset,
+                        sort.fetch,
+                        false
+                );
+
+                call.transformTo(
+                        new IgniteLimit(cluster, traits, convert(igniteSort, 
traits), sort.offset, sort.fetch),
+                        Map.of(
+                                new IgniteLimit(cluster, traits, 
convert(sort.getInput(), traits), sort.offset, sort.fetch),
+                                sort
+                        )
+                );
+            }
         } else {
             RelTraitSet outTraits = 
cluster.traitSetOf(IgniteConvention.INSTANCE).replace(sort.getCollation());
             RelTraitSet inTraits = 
cluster.traitSetOf(IgniteConvention.INSTANCE);
             RelNode input = convert(sort.getInput(), inTraits);
 
-            call.transformTo(new IgniteSort(cluster, outTraits, input, 
sort.getCollation()));
+            call.transformTo(new IgniteSort(cluster, outTraits, input, 
sort.getCollation(), false));

Review Comment:
   extra enforcer has been removed



-- 
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]

Reply via email to