You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "lowka (via GitHub)" <gi...@apache.org> on 2023/02/22 07:36:43 UTC

[GitHub] [ignite-3] lowka commented on a diff in pull request #1629: IGNITE-18479: ports

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


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/rel/IgniteSort.java:
##########
@@ -42,20 +45,52 @@
  * Ignite sort operator.
  */
 public class IgniteSort extends Sort implements IgniteRel {
+    /**
+     * Enforcer flag.
+     */
+    private final boolean enforcer;

Review Comment:
   I think this flag is redundant because the base class defines this property in the exactly same way (see another comment in SortConverterRule).



##########
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:
   When a sort operator neither have limit nor offset, the sort operator becomes _non_ enforcer? This is looks like a bug.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org