korlov42 commented on a change in pull request #8812:
URL: https://github.com/apache/ignite/pull/8812#discussion_r579231173



##########
File path: 
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AggregateNode.java
##########
@@ -95,6 +95,13 @@ public AggregateNode(ExecutionContext<Row> ctx, RelDataType 
rowType, AggregateTy
         }
 
         grpSet = b.build();
+
+        if (type == AggregateType.REDUCE || type == AggregateType.SINGLE)

Review comment:
       It's better to move this to `Grouping` constructor. And please leave a 
few words describing why don't we do the same for MAP aggregate

##########
File path: 
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/AggregatesIntegrationTest.java
##########
@@ -74,32 +74,48 @@ public void countOfNonNumericField() throws 
InterruptedException {
         person.put(idx++, new Employer(null, 15d));
         person.put(idx++, new Employer("Ilya", 15d));
         person.put(idx++, new Employer("Roma", 10d));
+        person.put(idx++, new Employer("Roma", 10d));
+
+        assertQuery("select count(name) from person").returns(4L).check();
+        assertQuery("select count(*) from person").returns(5L).check();
+        assertQuery("select count(1) from person").returns(5L).check();
 
-        assertQuery("select count(name) from person").returns(3L).check();
-        assertQuery("select count(*) from person").returns(4L).check();
-        assertQuery("select count(1) from person").returns(4L).check();
+        assertQuery("select count(*) from person where salary < 
0").returns(0L).check();
+        assertQuery("select count(*) from person where salary < 0 and salary > 
0").returns(0L).check();
 
-        assertQuery("select count(case when name like 'R%' then 1 else null 
end) from person").returns(1L).check();
-        assertQuery("select count(case when name not like 'I%' then 1 else 
null end) from person").returns(1L).check();
+        assertQuery("select count(case when name like 'R%' then 1 else null 
end) from person").returns(2L).check();
+        assertQuery("select count(case when name not like 'I%' then 1 else 
null end) from person").returns(2L).check();
 
         assertQuery("select count(name) from person where salary > 
10").returns(1L).check();
         assertQuery("select count(*) from person where salary > 
10").returns(2L).check();
         assertQuery("select count(1) from person where salary > 
10").returns(2L).check();
 
         assertQuery("select salary, count(name) from person group by salary 
order by salary")
-            .returns(10d, 2L)
+            .returns(10d, 3L)
             .returns(15d, 1L)
             .check();
 
         assertQuery("select salary, count(*) from person group by salary order 
by salary")
-            .returns(10d, 2L)
+            .returns(10d, 3L)
             .returns(15d, 2L)
             .check();
 
         assertQuery("select salary, count(1) from person group by salary order 
by salary")
-            .returns(10d, 2L)
+            .returns(10d, 3L)
             .returns(15d, 2L)
             .check();
+
+        assertQuery("select salary, count(1), sum(1) from person group by 
salary order by salary")
+            .returns(10d, 3L, 3)
+            .returns(15d, 2L, 2)
+            .check();
+
+        assertQuery("select salary, name, count(1), sum(salary) from person 
group by salary, name order by salary")

Review comment:
       let's add one more test to verify that for explicit grouping result set 
will not contain any rows

##########
File path: 
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AggregateNode.java
##########
@@ -95,6 +95,13 @@ public AggregateNode(ExecutionContext<Row> ctx, RelDataType 
rowType, AggregateTy
         }
 
         grpSet = b.build();
+
+        if (type == AggregateType.REDUCE || type == AggregateType.SINGLE)

Review comment:
       Also curly braces is required for `if` since its body is not one liner

##########
File path: 
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/agg/GroupKey.java
##########
@@ -23,6 +23,9 @@
  *
  */
 public class GroupKey {
+    /** */
+    public static final GroupKey EMPTY_GRP_KEY = new GroupKey(new Object[0]);

Review comment:
       let's reuse `X.EMPTY_OBJECT_ARRAY`




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to