xuzifu666 commented on code in PR #4983:
URL: https://github.com/apache/calcite/pull/4983#discussion_r3360259709
##########
core/src/test/java/org/apache/calcite/test/enumerable/EnumerableSortedAggregateTest.java:
##########
@@ -216,6 +216,21 @@ public class EnumerableSortedAggregateTest {
"deptno=20; total_distinct_salary=8000.0");
}
+ @Test void countDistinctWithOrderByNonGroupColumn() {
Review Comment:
I updated test case, Based on the PostgreSQL results
https://onecompiler.com/postgresql/44rcggaqf, it looks like it's OK.
##########
core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java:
##########
@@ -864,6 +920,23 @@ private static int remap(ImmutableBitSet groupSet, int
arg) {
return arg < 0 ? -1 : groupSet.indexOf(arg);
}
+ private static RelCollation remapCollationForGroupingSets(RelCollation
collation,
+ ImmutableBitSet fullGroupSet) {
+ if (collation.equals(RelCollations.EMPTY)) {
+ return RelCollations.EMPTY;
+ }
+ // Remap each field index through the fullGroupSet
+ final List<RelFieldCollation> remappedFCs = new ArrayList<>();
+ for (RelFieldCollation fc : collation.getFieldCollations()) {
+ int originalIdx = fc.getFieldIndex();
+ int newIdx = fullGroupSet.indexOf(originalIdx);
+ if (newIdx >= 0) {
+ remappedFCs.add(fc.withFieldIndex(newIdx));
Review Comment:
OK, I had add comment and add a test case cover this case.
I test it in postgresql and result is expected.
link:https://onecompiler.com/postgresql/44rcggaqf
--
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]