Skip to content

feat(DQL): @groupby on scalar fields and count duplicate (#7746) #8550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

MichelDiz
Copy link
Contributor

@MichelDiz MichelDiz commented Dec 21, 2022

PS. This PR depends A LOT in the Roaring Bitmaps. ref: 1134839

This PR extends support for var inside the @groupby query on a scalar predicate at root.
for example the given query now doesn't result to error:-

var(func: ... ) @groupby(age) {
  c as count(uid)
}

Now the uid variable c contains map of uid to count of uids with the same age.
Suppose for the data :-

        "uid": "0x1",
        "age": 38
      },
      {
        "uid": "0x17",
        "age": 15
      },
      {
        "uid": "0x18",
        "age": 15
      },
      {
        "uid": "0x19",
        "age": 17
      }

The following groupby query:-

var(func: uid(1, 23, 24, 25)) @groupby(age) {
      c as count(uid)
}
 me(func: uid(c)) {
      uid
      val(c)
}

returns the result:-

"data": {
    "me": [
      {
        "uid": "0x1",
        "val(c)": 1
      },
      {
        "uid": "0x17",
        "val(c)": 2
      },
      {
        "uid": "0x18",
        "val(c)": 2
      },
      {
        "uid": "0x19",
        "val(c)": 1
      }
    ]
  }

The behaviour will be the same if there are multiple predicates and some of them are uid predicates.
However, it is only supported at root currently. Hence the given query will still return error:-

var(func: .....) {
   friend @groupby(age) {
       a as count(uid)
   }
}

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@skrdgraph
Copy link
Contributor

@MichelDiz - this is failing the build phase of the test. I would suggest you to make this a draft PR - and test things locally before opening it up for review.

@MichelDiz
Copy link
Contributor Author

Closing, Follow this issue #8538

@MichelDiz MichelDiz closed this Feb 11, 2023
@MichelDiz MichelDiz deleted the micheldiz/cherry-pick#7746 branch February 11, 2023 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants