• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dgraph-io / dgraph / 6000148643
66%

Build:
DEFAULT BRANCH: main
Ran 28 Aug 2023 01:49PM UTC
Jobs 1
Files 251
Run time 8s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

28 Aug 2023 12:58PM UTC coverage: 67.112% (+0.5%) from 66.655%
6000148643

push

web-flow
feat(dql): add @unique constraint support in schema for new predicates (#8827)

Partially Fixes #8827
Closes: DGRAPHCORE-206
Docs PR: https://github.com/dgraph-io/dgraph-docs/pull/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>

347 of 347 new or added lines in 8 files covered. (100.0%)

58763 of 87560 relevant lines covered (67.11%)

2200726.47 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
1
0.0
0.0% dgraph/cmd/live/batch.go
1
85.82
0.79% worker/mutation.go
5
8.48
0.0% dgraph/cmd/live/run.go
25
81.3
1.15% edgraph/server.go
42
43.49
1.49% protos/pb/pb.pb.go

Uncovered Existing Lines

Lines Coverage ∆ File
2
54.97
-0.62% dgraph/cmd/bulk/loader.go
2
81.13
0.0% dgraph/cmd/zero/oracle.go
2
71.62
-0.25% dgraph/cmd/zero/raft.go
2
88.95
-1.1% graphql/subscription/poller.go
2
55.16
-0.47% worker/online_restore.go
4
83.92
-1.01% dgraph/cmd/zero/assign.go
4
82.62
0.48% worker/task.go
5
84.07
-0.93% conn/node.go
5
86.15
4.33% conn/pool.go
13
63.39
-1.19% dgraph/cmd/zero/zero.go
24
43.49
1.49% protos/pb/pb.pb.go
Jobs
ID Job ID Ran Files Coverage
1 6000148643.1 28 Aug 2023 01:49PM UTC 251
67.11
Source Files on build 6000148643
  • Tree
  • List 251
  • Changed 164
  • Source Changed 0
  • Coverage Changed 20
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 92c5b7a7 on github
  • Prev Build on main (#5985667653)
  • Next Build on main (#6012952056)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc