-
Notifications
You must be signed in to change notification settings - Fork 53
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: Add ability to explain sortNode
attribute(s).
#558
Conversation
4572a28
to
3512e0c
Compare
Codecov Report
@@ Coverage Diff @@
## develop #558 +/- ##
===========================================
+ Coverage 55.95% 56.08% +0.13%
===========================================
Files 121 121
Lines 14191 14231 +40
===========================================
+ Hits 7940 7982 +42
+ Misses 5553 5549 -4
- Partials 698 700 +2
|
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.
Approving assuming you address the 2 formatting points I've raised.
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.
Got a couple of comments on the tests but nothing too serious. Looks good!
3512e0c
to
596f6fd
Compare
596f6fd
to
31ba024
Compare
todo: Still have to add the test where you can sort/order the parent by its child.
fb5e08f
to
e669138
Compare
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 #584 should be solved here as it looks like an explain bug, but otherwise looks good
@@ -106,6 +106,13 @@ type OrderCondition struct { | |||
Direction SortDirection | |||
} | |||
|
|||
func (oc OrderCondition) IsEmpty() bool { | |||
if oc.Direction == "" && len(oc.FieldIndexes) == 0 { |
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.
suggestion: I think oc.Direction == ""
is not useful and this should only check len(oc.FieldIndexes)
. If it is impossible for only one of these to be true, then it is misleading and wasteful, if it is possible for direction to be empty and field indexes to be populated then that IMO is something that the sortNode could handle (could be a default direction for example).
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 would like to check for Direction
because if it is not empty then would like to have it dumped, this check was mainly put because I noticed that sortNode.ordering
has a bunch of empty elements (i.e. elements in ordering
having both Direction == ""
and len(FieldIndexes) == 0
). Can be handled inside sortNode
for sure, I find more clarity having this IsEmpty
function handle that but don't mind moving it into sortNode
if you have a strong preference for it.
function also look and ChildMappings to find the name of the index, Add the test that was failing before, also make `TryToFindNameFromIndex` now follow the boolean try pattern instead of returning error.
556cd1c
to
4857a7b
Compare
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.
Looks good Shahzad. I do still disagree RE the IsEmpty stuff, but that is unimportant. I alse see tracking down why there are empties there as out of scope.
@@ -455,7 +455,7 @@ func (p *Planner) explainRequest( | |||
|
|||
explainGraph, err := buildExplainGraph(plan) | |||
if err != nil { | |||
return nil, err | |||
return nil, multiErr(err, plan.Close()) |
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.
:) This smells like the similar Close issue I saw a while ago. Good find
) - Relevant issue(s): Resolves sourcenetwork#481. Fixes sourcenetwork#584 ([2] case). - Description Adds the attributes for `sortNode` to be included in the returned explain graph response. So far, we are only introducing 1 attribute, which represents a list containing all the `orderings` of each field requested to be sorted, with its corresponding direction. - Request: ``` query @Explain { author(order: {age: ASC}) { name age verified } } ``` - Response: ``` { "explain": { "selectTopNode": { "sortNode": { "selectNode": { "filter": null, "scanNode": { "filter": null, "collectionID": "3", "collectionName": "author", "spans": []{ { "start": "/3", "end": "/4", } } } } "orderings": []{ { "direction": "ASC", "fields": [ "age" ], } } } } } } ```
Relevant issue(s)
Resolves #481.
Fixes #584 ([2] case).
Description
Adds the attributes for
sortNode
to be included in the returned explain graph response.So far, we are only introducing 1 attribute, which represents a list containing all the
orderings
of each field requested to be sorted, with its corresponding direction.Example:
Request:
Response:
Limitations:
Tasks
How has this been tested?
Integration tests locally and only CI. Specifically
make test
.Specify the platform(s) on which this was tested: