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 2021/02/18 14:27:37 UTC

[GitHub] [ignite] ygerzhedovich opened a new pull request #8812: IGNITE-14156: Return zero results for aggregates.

ygerzhedovich opened a new pull request #8812:
URL: https://github.com/apache/ignite/pull/8812


   Thank you for submitting the pull request to the Apache Ignite.
   
   In order to streamline the review of the contribution 
   we ask you to ensure the following steps have been taken:
   
   ### The Contribution Checklist
   - [ ] There is a single JIRA ticket related to the pull request. 
   - [ ] The web-link to the pull request is attached to the JIRA ticket.
   - [ ] The JIRA ticket has the _Patch Available_ state.
   - [ ] The pull request body describes changes that have been made. 
   The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
   - [ ] The pull request title is treated as the final commit message. 
   The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
   - [ ] A reviewer has been mentioned through the JIRA comments 
   (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) 
   - [ ] The pull request has been checked by the Teamcity Bot and 
   the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
   
   ### Notes
   - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
   - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
   - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
   - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
   
   If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [ignite] korlov42 commented on a change in pull request #8812: IGNITE-14156: Return zero results for aggregates.

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org