diff --git a/dgraph/cmd/bulk/reduce.go b/dgraph/cmd/bulk/reduce.go index ae466f9fe50..3927f4d0cf0 100644 --- a/dgraph/cmd/bulk/reduce.go +++ b/dgraph/cmd/bulk/reduce.go @@ -611,7 +611,7 @@ func (r *reducer) toList(req *encodeRequest) { enc := codec.Encoder{BlockSize: 256} var lastUid uint64 slice, next := []byte{}, start - for next >= 0 && (next < end || end == 0) { + for next >= 0 && (next < end || end == -1) { slice, next = cbuf.Slice(next) me := MapEntry(slice) diff --git a/systest/bulk_live/common/bulk_live_cases.go b/systest/bulk_live/common/bulk_live_cases.go index df9d65ed238..cb0138c4cdd 100644 --- a/systest/bulk_live/common/bulk_live_cases.go +++ b/systest/bulk_live/common/bulk_live_cases.go @@ -55,6 +55,10 @@ func RunBulkCases(t *testing.T) { testCountIndex(t) suite.cleanup() + suite = indexedPredicateSetup(t, true) + testIndexedPredicate(t) + suite.cleanup() + suite = loadTypesSetup(t, true) testLoadTypes(t) suite.cleanup() @@ -78,6 +82,10 @@ func RunLiveCases(t *testing.T) { testFacets(t) suite.cleanup() + suite = indexedPredicateSetup(t, false) + testIndexedPredicate(t) + suite.cleanup() + suite = countIndexSetup(t, false) testCountIndex(t) suite.cleanup() @@ -217,6 +225,42 @@ func testFacets(t *testing.T) { `)) } +func indexedPredicateSetup(t *testing.T, isBulkLoader bool) *suite { + if isBulkLoader { + s := newBulkOnlySuite(t, ` + name: string @index(exact) . + `, ` + _:a "alice" . + _:b "alice" . + `, "") + return s + } + + s := newLiveOnlySuite(t, ` + name: string @index(exact) . + `, ` + _:a "alice" . + _:b "alice" . + `, "") + return s +} + +func testIndexedPredicate(t *testing.T) { + t.Run("Count query", testCase(` + { + get_count(func: eq(name, "alice")) { + count(uid) + }, + } + `, ` + { + "get_count": [ + { "count": 2 } + ] + } + `)) +} + func countIndexSetup(t *testing.T, isBulkLoader bool) *suite { schema := ` name: string @index(exact) .