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

Add support for expand on type #3949

Closed
wants to merge 1 commit into from
Closed

Add support for expand on type #3949

wants to merge 1 commit into from

Conversation

poonai
Copy link
Contributor

@poonai poonai commented Sep 9, 2019

close #3903
This PR will add support to use type on expand function.

Changes made

  • Removed restriction in expand function for using only the specified keyword like _all_. Now expand function can take any paramenter. But the given parameter should be assoicated with type.
  • subgraph is expanded from the type predicates.

Now, user can query like this

{
  q(func: type(Person)) {
    dgraph.type
    expand(Person)
  }
}

Signed-off-by: பாலாஜி ஜின்னா [email protected]


This change is Reviewable

Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
@poonai poonai requested a review from a team as a code owner September 9, 2019 15:07
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ A review job has been created and sent to the PullRequest network.


@balajijinnah you can click here to see the review status or cancel the code review job.

span.Annotate(nil, fmt.Sprintf("expand(%s)", child.Params.Expand))
_, ok := types[child.Params.Expand]
if !ok {
return out, errors.Errorf("Invalid expand type %d", child.Params.Expand)

Choose a reason for hiding this comment

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

printf: Errorf format %d has arg child.Params.Expand of wrong type string (from govet)

if !ok {
return out, errors.Errorf("Invalid expand type %d", child.Params.Expand)
}
preds = getPredicatesFromTypes(map[string]struct{}{child.Params.Expand: struct{}{}})

Choose a reason for hiding this comment

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

File is not gofmt-ed with -s (from gofmt)

Suggested change
preds = getPredicatesFromTypes(map[string]struct{}{child.Params.Expand: struct{}{}})
preds = getPredicatesFromTypes(map[string]struct{}{child.Params.Expand: {}})

Copy link
Contributor

@mangalaman93 mangalaman93 left a comment

Choose a reason for hiding this comment

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

Please add test cases and fix CI build and create a corresponding GitHub issue if one is already not there.

// We already have the predicates populated from the var.
preds = getPredsFromVals(child.ExpandPreds)
// If type exist in expand function, check whether that type exist for the node or not.
// If not then thorow error. If exist obtain all the predicate for the type and expand
Copy link
Contributor

Choose a reason for hiding this comment

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

throw*

if !ok {
return out, errors.Errorf("Invalid expand type %d", child.Params.Expand)
}
preds = getPredicatesFromTypes(map[string]struct{}{child.Params.Expand: struct{}{}})
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we converting this into string?

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

The change itself looks good to me but

  1. Are there any associated test cases with these files? Please update them if there are - or consider adding them if they are not present alredy (I would assume the former for this repo)
  2. Please make any documentation changes if necessary to reflect your change.

Reviewed with ❤️ by PullRequest

Copy link
Contributor

@martinmr martinmr left a comment

Choose a reason for hiding this comment

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

  1. I already have a PR to do this Add ability to expand only on certain types. #3920
  2. This needs tests.
  3. The test will probably fail if you run a query like
expand(Person) {
    uid
}

some uids that should not show up will show up in that case. That's the reason my PR is still a draft. I need to figure out what the issue is.

Reviewable status: 0 of 2 files reviewed, 3 unresolved discussions (waiting on @animesh2049, @balajijinnah, @gitlw, @golangcibot, @manishrjain, and @martinmr)

Copy link
Contributor

@martinmr martinmr left a comment

Choose a reason for hiding this comment

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

Also, we shouldn't get rid of all, reverse, etc. The type argument is an addition, not a replacement to the current expand functionality.

Reviewable status: 0 of 2 files reviewed, 3 unresolved discussions (waiting on @animesh2049, @balajijinnah, @gitlw, @golangcibot, and @manishrjain)

@poonai
Copy link
Contributor Author

poonai commented Sep 9, 2019

I'm closing this.

@poonai poonai closed this Sep 9, 2019
@joshua-goldstein joshua-goldstein deleted the balaji/expand_type branch August 19, 2022 00:19
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.

Support expand of types
4 participants