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

feat(Query): Allow filters in expand(_all_) queries on predicates pointing to nodes #6752

Merged
merged 3 commits into from
Oct 19, 2020

Conversation

all-seeing-code
Copy link
Contributor

@all-seeing-code all-seeing-code commented Oct 18, 2020

Motivation

Enable queries that can declare filters on predicates while using expand(_all_) directive.
Example:

q(func: eq(name, "Michonne")) {
	expand(_all_)
	friend @filter(eq(alive, true)){
		expand(_all_)
	}
}

Note: Queries that explicitly ask for scalar predicates while using expand(_all_) will continue to throw.

This PR fixes: DGRAPH-2524

Further discussion: https://discuss.dgraph.io/t/expand-with-predicate-filters/10611

Components affected by this PR

Query Package particularly queries involving expand(_all_) directive.

Does this PR break backwards compatibility?

No

Testing

Added following tests in:

  1. TestFilterAtSameLevelOnUIDWithExpand

Fixes

Fixes DGRAPH-2524


This change is Reviewable

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.

Reviewed 1 of 1 files at r1, 2 of 2 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @anurags92)


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

		return false
	}
	// TODO(Anurag): Below check can be expanded to check deeper equivalence

Instead of a TODO, just mention what are the limitations of the current approach.


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

func TestFilterAtSameLevelOnUIDWithExpand(t *testing.T) {
	query := `{
		q(func: eq(name, "Michonne")) {

Can you try this as well?

michone {
  expand(_all_) {
    expand(_all_)
  }
  friend @filter(...) {
    expand(_all_)
  }
}
michonne {
  expand(_all_) {
    friend @filter(eq(alive, true)) {
      name
    }
  }
}

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

	js := processQueryNoErr(t, query)
	// res, _ := json.MarshalIndent(js, " ", "\t")
	fmt.Println("JS: ", string(js))

should be removed

@all-seeing-code all-seeing-code merged commit e64afe1 into master Oct 19, 2020
@all-seeing-code all-seeing-code deleted the anurags92/filtersInExpand branch October 19, 2020 20:23
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.

2 participants