Skip to content
This repository was archived by the owner on Mar 29, 2025. It is now read-only.
This repository was archived by the owner on Mar 29, 2025. It is now read-only.

[Documentation]: DQL requires a specific order when using @count with @recurse #461

@rahst12

Description

@rahst12

What version of Dgraph is the target?

v21.03.01

Documentation.

DQL requires a specific order when using @count with @recurse. The below examples illustrate the behavior based on DGraph Tour examples.

The @count documentation page should reflect the changed/abnormal behavior when used in conjunction with @recurse.

When returning a Predicate AND counting the same Predicate - the DQL Query must have the @count(predicate) ordered below the predicate in the DQL query.

The below examples can be replicated by following the steps 1-6 in the DGraph Tour: Graphs | Intro | Dgraph Tour

The query returns wrong data:
Note: The count of friend is above the predicate friend

{
  michael(func: eq(name, "Michael")) @recurse(depth:10){
    name
    age
    owns_pet
    friend~
    count(friend @filter(NOT eq(name, "Sarah")))
    friend @filter(NOT eq(name, "Sarah")) 
  }
}

image

The query returns correct data:
Note: The count of friend is below the predicate friend

{
  michael(func: eq(name, "Michael")) @recurse(depth:10){
    name
    age
    owns_pet
    friend~
    friend @filter(NOT eq(name, "Sarah"))
    count(friend @filter(NOT eq(name, "Sarah")))
  }
}

image

Details are in this discuss post: https://discuss.dgraph.io/t/does-order-in-a-dql-query-matter/18274/4

Additional information.

I honestly think this is a bug as well. The discus post had some conversation about what is correct vs. incorrect behavior of DGraph. I think at least DGraph should throw an error stating you can't put a count above a predicate when counting the same predicate. Ideally, the order of where the count is in the DQL shouldn't matter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions