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

Added Val support for JSON #3947

Merged
merged 3 commits into from
Sep 11, 2019
Merged

Conversation

harshil-goel
Copy link
Contributor

@harshil-goel harshil-goel commented Sep 9, 2019

This lets the user to use val function inside a JSON format upsert.

This change is Reviewable

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.


@harshil-goel you can click here to see the review status or cancel the code review job.

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.

1 Message
The description of this pull request is blank. Adding a high-level summary will help our reviewers provide better feedback.

chunker/json_parser_test.go Show resolved Hide resolved
}
}`
testutil.CompareJSON(t, res, expectedRes)

Copy link
Contributor

Choose a reason for hiding this comment

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

extra new line

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.

Reviewed 3 of 3 files at r1.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @harshil-goel and @manishrjain)


chunker/json_parser.go, line 155 at r1 (raw file):

		}

		if strings.HasPrefix(s, "val(") {

I would also add a check that the parenthesis are properly closed.


chunker/json_parser_test.go, line 599 at r1 (raw file):

}

func TestValInUpsert(t *testing.T) {

Add another test with an input such as {"uid":1000, "name": "val(name"} and make sure the parsing throws an error.

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: Still needs approval from other reviewers. Also, looks like their comments haven't been marked as Done (or addressed). So, do that and it's good to go.

Reviewed 3 of 3 files at r1.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @harshil-goel)

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 test strings.hasPrefix("val(") could benefit from accepting a constant value for readability. Please review the comment describing the issue.


Reviewed with ❤️ by PullRequest

@@ -152,6 +152,11 @@ func handleBasicType(k string, v interface{}, op int, nq *api.NQuad) error {
return nil
}

if strings.HasPrefix(s, "val(") {
Copy link

Choose a reason for hiding this comment

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

This is a somewhat unique structure to introspect for, should it be in a constant that others can use and or verify for correctness without looking for this exact string?

Copy link
Contributor Author

@harshil-goel harshil-goel 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, 5 unresolved discussions (waiting on @mangalaman93, @martinmr, and @pullrequest[bot])


chunker/json_parser.go, line 155 at r1 (raw file):

Previously, pullrequest[bot] wrote…

This is a somewhat unique structure to introspect for, should it be in a constant that others can use and or verify for correctness without looking for this exact string?

Done.


chunker/json_parser.go, line 155 at r1 (raw file):

Previously, martinmr (Martin Martinez Rivera) wrote…

I would also add a check that the parenthesis are properly closed.

It is done later while parsing the NQuad.


chunker/json_parser_test.go, line 599 at r1 (raw file):

Previously, martinmr (Martin Martinez Rivera) wrote…

Add another test with an input such as {"uid":1000, "name": "val(name"} and make sure the parsing throws an error.

Done.


chunker/json_parser_test.go, line 602 at r1 (raw file):

Previously, mangalaman93 (Aman Mangal) wrote…

check the structure of the returned object too.

Done.


dgraph/cmd/alpha/upsert_test.go, line 147 at r1 (raw file):

Previously, mangalaman93 (Aman Mangal) wrote…

extra new line

Done.

Copy link
Contributor Author

@harshil-goel harshil-goel 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: 0 of 3 files reviewed, 5 unresolved discussions (waiting on @mangalaman93, @manishrjain, @martinmr, and @pullrequest[bot])


chunker/json_parser.go, line 155 at r1 (raw file):

Previously, harshil-goel wrote…

It is done later while parsing the NQuad.

Actually, I got confused with RDF Lexing, and there was no such check. I have added the appropriate check now.

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.

Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on @manishrjain, @martinmr, and @pullrequest[bot])

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.

:lgtm:

Reviewed 3 of 3 files at r2.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @pullrequest[bot])

@harshil-goel harshil-goel merged commit 20136d5 into master Sep 11, 2019
@harshil-goel harshil-goel deleted the harshil-goel/val-parse-in-json branch September 11, 2019 19:15
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.

4 participants