-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
cascade directive at subqueries #4006
Conversation
There was a problem hiding this 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.
@animesh2049 you can click here to see the review status or cancel the code review job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query/common_test.go
Outdated
panic(fmt.Sprintf("Could not perform DropAll op. Got error %v", err.Error())) | ||
} | ||
|
||
schema := ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix the formatting!
query/common_test.go
Outdated
xname: string @index(term, exact) . | ||
xage: int . | ||
xfriend: [uid] . | ||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't leave any newlines here after multiline string
query/common_test.go
Outdated
setSchema(schema) | ||
|
||
data := ` | ||
_:animesh <xname> "Animesh" . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting
query/query0_test.go
Outdated
@@ -2287,5 +2287,6 @@ func TestMain(m *testing.M) { | |||
client = testutil.DgraphClientWithGroot(testutil.SockAddr) | |||
|
|||
populateCluster() | |||
insertSmallDataSet() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call it populateCascadeDataset()
query/common_test.go
Outdated
@@ -618,3 +618,31 @@ func populateCluster() { | |||
<307> <updated_at> "2019-05-28" (modified_at=2019-03-24T14:41:57+05:30) . | |||
`) | |||
} | |||
|
|||
func insertSmallDataSet() { | |||
err := client.Alter(context.Background(), &api.Operation{DropAll: true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not call dropall here, otherwise existing test will fail
query/query4_test.go
Outdated
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra newline
query/query4_test.go
Outdated
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The additional feedback outside of the existing comments are focused on readability.
Reviewed with ❤️ by PullRequest
query/common_test.go
Outdated
@@ -618,3 +618,31 @@ func populateCluster() { | |||
<307> <updated_at> "2019-05-28" (modified_at=2019-03-24T14:41:57+05:30) . | |||
`) | |||
} | |||
|
|||
func insertSmallDataSet() { | |||
err := client.Alter(context.Background(), &api.Operation{DropAll: true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the syntax here should change to reflect the struct initialization and obtaining a pointer value.
o := api.Operation{DropAll: true}
err := client.Alter(context.Background(), &o)
It is an additional line, but it certainly makes the code more readable in terms of what operations are occurring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 5 files at r1.
Reviewable status: 4 of 5 files reviewed, 9 unresolved discussions (waiting on @animesh2049, @mangalaman93, @manishrjain, and @pawanrawal)
query/common_test.go, line 623 at r1 (raw file):
Previously, pullrequest[bot] wrote…
I think the syntax here should change to reflect the struct initialization and obtaining a pointer value.
o := api.Operation{DropAll: true} err := client.Alter(context.Background(), &o)It is an additional line, but it certainly makes the code more readable in terms of what operations are occurring.
Right now all the data for tests is added in the populateCluster method. Not great since new data could potentially break existing tests but it's better than removing data in each test.
query/query0_test.go, line 2290 at r1 (raw file):
populateCluster() insertSmallDataSet()
remove this function and move all the data insertion to populateCluster. We shouldn't have multiple places where data is inserted. We are already doing this for facet tests and it's kind of a pain in the ass.
query/query4_test.go, line 23 at r1 (raw file):
Quoted 4 lines of code…
// "encoding/json" // "fmt" // "strings" func TestTypeExpandLang(t *testing.T) { ⋯ expand 9 lines
can you remove the commented imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments -
- Fix the JSON formatting, doesn't look good
- Add a test for multiple cascade in a query
Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @animesh2049, @manishrjain, @martinmr, and @pawanrawal)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @manishrjain, @martinmr, and @pawanrawal)
query/query0_test.go, line 2290 at r1 (raw file):
Previously, martinmr (Martin Martinez Rivera) wrote…
remove this function and move all the data insertion to populateCluster. We shouldn't have multiple places where data is inserted. We are already doing this for facet tests and it's kind of a pain in the ass.
Done.
query/query4_test.go, line 23 at r1 (raw file):
Previously, martinmr (Martin Martinez Rivera) wrote…
// "encoding/json" // "fmt" // "strings" func TestTypeExpandLang(t *testing.T) { ⋯ expand 9 lines
can you remove the commented imports?
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work. I only have two suggestions, make tests start with multiple source uids to make them representative of the general use-case and add some comments to them to make it easier for the reviewer and the person looking at them later.
Reviewed 2 of 5 files at r1, 2 of 3 files at r2.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @animesh2049, @manishrjain, and @martinmr)
query/query4_test.go, line 341 at r2 (raw file):
} func TestCascadeSubQuery1(t *testing.T) {
Can you add a comment about this test. In general it would be nice to explain your tests or make the name more descriptive than SubQuery1, SubQuery2 so that others who look at it later know what the intention of the test is.
I am assuming that Michonne has some friends who don't have a full_name
and hence they are removed? Or is it that Michonne's friends friend don't have all the fields name
, full_name
...?
query/query4_test.go, line 344 at r2 (raw file):
query := ` { me(func: uid(0x01)) {
Could you update your tests to start with more than one source uid, have atleast three.
query/query4_test.go, line 407 at r2 (raw file):
"friend": [ { "name": "Rick Grimes",
I am assuming Rick has more friends but only Michonne is the friend with all the fields? If yes, then please explain in a comment.
query/query4_test.go, line 433 at r2 (raw file):
} func TestCascadeSubQuery3(t *testing.T) {
TestCascadeRepeatedMultipleLevels(t *testing.T) and add a comment saying that it should be the same as only applying it at the top level friend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 3 files reviewed, 6 unresolved discussions (waiting on @manishrjain, @martinmr, and @pawanrawal)
query/query4_test.go, line 341 at r2 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
Can you add a comment about this test. In general it would be nice to explain your tests or make the name more descriptive than SubQuery1, SubQuery2 so that others who look at it later know what the intention of the test is.
I am assuming that Michonne has some friends who don't have a
full_name
and hence they are removed? Or is it that Michonne's friends friend don't have all the fieldsname
,full_name
...?
Done.
query/query4_test.go, line 344 at r2 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
Could you update your tests to start with more than one source uid, have atleast three.
Done.
query/query4_test.go, line 407 at r2 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
I am assuming Rick has more friends but only Michonne is the friend with all the fields? If yes, then please explain in a comment.
Added an extra test with explanation.
query/query4_test.go, line 433 at r2 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
TestCascadeRepeatedMultipleLevels(t *testing.T) and add a comment saying that it should be the same as only applying it at the top level friend.
Done.
This change is
related to #1755