Null values returned on combination of "count" and sum on aggregate query for child nodes

Report a Dgraph Bug

When doing a aggregate query on child nodes (Max/Min/Sum, null values are returned when adding “count”

What version of Dgraph are you using?

21.3.0-slash
$ dgraph version
 
Dgraph version   : v21.03.0-63-g8b9e92314
Dgraph codename  : rocket
Dgraph SHA-256   : 0f3b429d3a8d478e215fad5f28acbccb1ab4b10de62ae9a914675bcc555fc3b6
Commit SHA-1     : 8b9e92314
Commit timestamp : 2021-06-28 14:33:43 +0530
Branch           : release/v21.03-slash
Go version       : go1.16.2
jemalloc enabled : true

For Dgraph official documentation, visit https://dgraph.io/docs.
For discussions about Dgraph     , visit https://discuss.dgraph.io.
For fully-managed Dgraph Cloud   , visit https://dgraph.io/cloud.

Licensed variously under the Apache Public License 2.0 and Dgraph Community License.
Copyright 2015-2021 Dgraph Labs, Inc.

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, OS)?

16 GB RAM, Ubuntu Linux

Steps to reproduce the issue (command/config used to run Dgraph).

First issuing a query without “count”:

{
  getCompany(id: "585a72e3ca6e02010016dd57") {
    licensesAggregate(filter: {
      currency: {
        allofterms: "USD"
      }
    }) {
      priceSum
      numberMax
    }
  }
}

Resulting in good values:

{
  "data": {
    "getCompany": {
      "licensesAggregate": {
        "priceSum": 2691,
        "numberMax": 6052
      }
    }
  }
}

No adding the “count” to the child node aggregate “licensesAggregate”:

{
  getCompany(id: "585a72e3ca6e02010016dd57") {
    licensesAggregate(filter: {
      currency: {
        allofterms: "USD"
      }
    }) {
      priceSum
      numberMax
      count
    }
  }
}

This gives back null values for the aggregates that are not count:

{
  "data": {
    "getCompany": {
      "licensesAggregate": {
        "priceSum": null,
        "numberMax": null,
        "count": 78
      }
    }
  }
}

Expected behaviour and actual result.

In this case: the “priceSum” and “numberMax” not to be null