-
Notifications
You must be signed in to change notification settings - Fork 51
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: Support for descending fields CLI index creation #3237
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3237 +/- ##
===========================================
- Coverage 77.61% 77.49% -0.12%
===========================================
Files 382 382
Lines 35236 35263 +27
===========================================
- Hits 27345 27324 -21
- Misses 6272 6308 +36
- Partials 1619 1631 +12
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 13 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
todo: I will be adding integration tests for this. |
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. Tests would be great. Actually I don't know why there is no tests for this yet. I might have missed this case.
You can look into tests/integration/index/query_with_composite_index_field_order_test.go
and tests/integration/index/query_with_index_only_field_order_test.go
. Just copy&paste one of the tests and instead of including an index into testUtils.SchemaUpdate
create another testUtils.CreateIndex
with whatever params you deem appropriate.
Our integration tests will run for all 3 clients: go client, HTTP and CLI. So whatever action you write in integration tests will be translated to the "language" of these 3 clients. So you will have to change CreateIndex
method in tests/clients/cli/wrapper_collection.go
.
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.
One thing that needs to be added is documentation. Please make sure you include the new change. Couldn't leave an inline comment as you didn't change that part. It's the description in cli/index_create.go
.
After this you can run make docs
to sync docs with other places.
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 really good Chris, solution is nice and simple, and easy to read. Am curious as to how nice/miserable you found writing that first integration test? Congrats on your first PR :)
I have a couple of minor suggestions for you, please respond to them before merging (your response can very much be 'no I think that is a bad idea because of xyz'), as well as making sure Islam and any other reviewers are of course happy :)
I discussed the way the CreateIndex function is written with Andy. Currently, it takes in an IndexDescription object. Because of this, the function has access to a boolean indicating whether or not the order should be descending. However, the function does not have access to any context indicating whether a false value means ":ASC" was explicitly passed in, or because nothing was passed in explicitly, and the default value (ascending order) was used. |
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.
LGTM! Good job, Chris.
bug bash result: run different combinations of composite indexes with different directions. Everything work fine. |
Relevant issue(s)
Resolves #2460
Description
Using the HTTP endpoint, it was possible to create a collection index, with each field being either descending or ascending. This was possible because one of the parameters was a boolean field called "Descending." However, this functionality was not present in the CLI equivalent.
This feature adds support for creating descending fields.
For example, the following sorts name in ascending order, because ascension is the default
defradb client index create -c User --fields name
The following sorts it in descending order:
defradb client index create -c User --fields name:DESC
And the following sorts multiple fields, in different combinations of descending and ascending order:
defradb client index create -c User --fields name:ASC,score:DESC
Tasks
How has this been tested?
Specify the platform(s) on which this was tested: