-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dql): add @unique constraint support in schema for new predicates (
#8827) 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] - [ ] check if @unique can be added to schema depending upon whether existing data has any duplicates. If the existing data has any duplicates, we do not allow adding the @unique directive and return a query that allows user to identify these UIDs. - [ ] If index computation is in progress, we should not allow mutations with predicates for which @unique is set - [ ] Fix ACL to ensure that we do not end up adding duplicate users - [ ] Ensure that unique constraint is not violated during Bulk loader --------- Co-authored-by: Aman Mangal <aman@dgraph.io>
- Loading branch information
1 parent
9a964dd
commit 92c5b7a
Showing
12 changed files
with
1,564 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.