-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
add @unique constraint support in schema for new predicates #8827
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, this looks pretty good to start with. We need to add test for parsing the schema.
46cbb2c
to
e42effd
Compare
bef7d2e
to
426dcd0
Compare
426dcd0
to
df12adc
Compare
df12adc
to
0d36865
Compare
b427ed9
to
3c624b4
Compare
3c624b4
to
e35112a
Compare
e35112a
to
8792076
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should for now, do not allow adding unique when the predicate already exists. Later on, we can support unique for existing predicate as well.
8792076
to
ebd101c
Compare
ebd101c
to
147d518
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good to me now. 3 very minor comments. Please ask other people to review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will need a meeting to go through the various design decisions.
147d518
to
683a212
Compare
683a212
to
3eb7565
Compare
3eb7565
to
234a288
Compare
234a288
to
71e5a42
Compare
What is the behavior if you add @unique on an existing predicate and deploy the schema? |
we reject the schema and the Alter request should return an error. |
Partially Fixes #8827
Closes: DGRAPHCORE-206
Docs PR: dgraph-io/dgraph-docs#638
This PR adds support for uniqueness constraint using @unique directive in DQL schema. This unique directive ensures that all values of the predicate are different in a Dgraph Cluster. This completes phase 1, and enables adding a new predicate with unique directive. As part of the phase 2, we will work on adding support for unique directive for existing predicates.
Performance
Live Loader before this change on 21 million dataset took 10m54s whereas after this change took 11m02s. It did not make any significant different to non-unique predicates.
How to Use
You can now specify unique in schema as follows:
email: string @unique @index(hash) @upsert .
. Now, Dgraph will ensure that no mutation adds a duplicate for the predicate email.Phase 2 [TODO]