Skip to content
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

Fix has pagination when predicate is queried with @lang #4331

Merged
merged 5 commits into from
Dec 11, 2019

Conversation

ashish-goswami
Copy link
Contributor

@ashish-goswami ashish-goswami commented Nov 27, 2019

Fixes #4282


This change is Reviewable

worker/task.go Outdated Show resolved Hide resolved
@ashish-goswami ashish-goswami marked this pull request as ready for review December 4, 2019 13:50
Copy link
Contributor

@animesh2049 animesh2049 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r2.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @golangcibot, @mangalaman93, @manishrjain, and @pawanrawal)

Copy link
Contributor

@pawanrawal pawanrawal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @ashish-goswami, @golangcibot, @mangalaman93, and @manishrjain)


query/query4_test.go, line 602 at r2 (raw file):

// func TestHasFirstLangPredicate(t *testing.T) {
// 	query := `{
// 		q(func:has(name@lang), orderasc: name, first:5) {

This won't work but a test case which is just calling the has function on a predicate with a lang and first should work? Could we add that please?


worker/task.go, line 2096 at r2 (raw file):

	lang := langForFunc(q.Langs)
	needFiltering := needsStringFiltering(srcFn, q.Langs, q.Attr)
	checkInclusion := func(uid uint64) error {

Add some comments that what we are fetching the value for the uid + predicate@lang here before deciding if we want to include the uid in the result.


worker/task.go, line 2101 at r2 (raw file):

		}

		_, err := qs.getValsForUID(q.Attr, lang, uid, q.ReadTs)

Since this would only be called if there is a language, we don't need the extra logic in getValsForUID corresponding to lang == ""

Copy link
Contributor Author

@ashish-goswami ashish-goswami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dismissed @golangcibot from a discussion.
Reviewable status: 1 of 2 files reviewed, 3 unresolved discussions (waiting on @animesh2049, @lang, @mangalaman93, @manishrjain, and @pawanrawal)


query/query4_test.go, line 602 at r2 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

This won't work but a test case which is just calling the has function on a predicate with a lang and first should work? Could we add that please?

First might return result in any order. Hence I won't be able to compare it. I have added test for count though.


worker/task.go, line 2096 at r2 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

Add some comments that what we are fetching the value for the uid + predicate@lang here before deciding if we want to include the uid in the result.

Done.


worker/task.go, line 2101 at r2 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

Since this would only be called if there is a language, we don't need the extra logic in getValsForUID corresponding to lang == ""

We need it in case predicate supports @lang. When lang is "", we need to get all uids which does not have @lang(there might be no posting for this). We predicate is list, this function won't be called from
handleHasFunction.

Copy link
Contributor

@pawanrawal pawanrawal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 2 files at r2, 1 of 1 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ashish-goswami, @mangalaman93, and @manishrjain)


query/query4_test.go, line 633 at r3 (raw file):

func TestHasCountPredicateWithLang(t *testing.T) {
	query := `{
		q(func:has(name@en), first: 5) {

Could we use a higher number here please which is equal to number of nodes which have name@en?

Copy link
Contributor Author

@ashish-goswami ashish-goswami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @animesh2049, @mangalaman93, @manishrjain, and @pawanrawal)


query/query4_test.go, line 633 at r3 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

Could we use a higher number here please which is equal to number of nodes which have name@en?

Done.

Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @animesh2049, @mangalaman93, @manishrjain, and @pawanrawal)

@ashish-goswami ashish-goswami merged commit d2204ea into master Dec 11, 2019
@ashish-goswami ashish-goswami deleted the ashish/issue-4282 branch December 11, 2019 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

has function with pagination (first) does not return correct count
5 participants