You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/03/16 12:58:02 UTC

[GitHub] [ignite-3] zstan commented on a change in pull request #707: IGNITE-16656 Adoption of a bunch of calcite related tickets from Ignite-2 part3

zstan commented on a change in pull request #707:
URL: https://github.com/apache/ignite-3/pull/707#discussion_r827978477



##########
File path: modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/rel/agg/IgniteSortAggregateBase.java
##########
@@ -50,10 +50,25 @@
     default Pair<RelTraitSet, List<RelTraitSet>> passThroughCollation(
             RelTraitSet nodeTraits, List<RelTraitSet> inputTraits
     ) {
-        RelCollation collation = RelCollations.of(ImmutableIntList.copyOf(getGroupSet().asList()));
+        RelCollation required = TraitUtils.collation(nodeTraits);
+        ImmutableBitSet requiredKeys = ImmutableBitSet.of(required.getKeys());
+        RelCollation collation;
+
+        if (getGroupSet().contains(requiredKeys)) {
+            List<RelFieldCollation> newCollationFields = new ArrayList<>(getGroupSet().cardinality());
+            newCollationFields.addAll(required.getFieldCollations());
+
+            ImmutableBitSet keysLeft = getGroupSet().except(requiredKeys);
+
+            keysLeft.forEach(fieldIdx -> newCollationFields.add(TraitUtils.createFieldCollation(fieldIdx)));
+
+            collation = RelCollations.of(newCollationFields);
+        } else {
+            collation = TraitUtils.createCollation(getGroupSet().toList());
+        }
 
         return Pair.of(nodeTraits.replace(collation),
-                List.of(inputTraits.get(0).replace(collation)));
+                ImmutableList.of(inputTraits.get(0).replace(collation)));

Review comment:
       ups, done




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