How does DQL judge whether a predicate has duplicate values in dgraph?
It doesn’t. You can have multiple duplicate values attached to a predicate. You can use @groupby
with an aggregate function to figure out how “unique” your preds are
What about arrays/sets?
I don’t think Dgraph has a Set
type.
ok, so if Dgraph does not support sets, then how does it support Arrays in a set like format in GQL when you cannot add a value more than once? Does it use groupby?
I think I should rephrase. It doesn’t have a Set
datatype in the surface language (DQL or Graphql). For details I’d ping @pawan .
Values within a list type for a predicate are actually hashed. So
type Person {
name: [String]
}
<1> <name> "AnthonyMaster"
<1> <name> "Anthony"
...
would all be stored inside a list for <1>, <name>
So <1>, <name> => [ hash<Anthony Master>, hash<Anthony>, ... ]
Therefore duplicate values hash to the same key and the add operation on list type [ ]
behaves like a set.