-
Notifications
You must be signed in to change notification settings - Fork 487
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
CosmosDBState - Add, as option, the partitionKey in QueryMethod #3227
Conversation
9ee628a
to
16ed7d1
Compare
state/azure/cosmosdb/cosmosdb.go
Outdated
@@ -92,8 +92,11 @@ func (p crossPartitionQueryPolicy) Do(req *policy.Request) (*http.Response, erro | |||
// Check if we're performing a query | |||
// In that case, remove the partitionkey header and enable cross-partition queries | |||
if strings.ToLower(raw.Header.Get("x-ms-documentdb-query")) == "true" { | |||
raw.Header.Add("x-ms-documentdb-query-enablecrosspartition", "true") | |||
raw.Header.Del("x-ms-documentdb-partitionkey") | |||
raw.Header.Add("x-ms-documentdb-query-enablecrosspartition", "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.
probably should be lowercase true
the way it was before
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.
Move this into the if-clause you added. This header should only be added when the partition key is fake. You do not want to run expensive cross partition queries otherwise.
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.
Generally the idea is right, but some small correction on the details. When to add headers etc
Also please do not define the new feature key / capability. That is only intended for features which we (at least at some point in time) intend to support in all state stores.
tests/conformance/state/state.go
Outdated
// Test for CosmosDB (filter test with partitionOnly) this query doesn't use the cross partition ( value from 2 different partitionKey %s-struct and %s-struct-2) | ||
{ | ||
query: ` | ||
{ | ||
"filter": { | ||
"OR": [ | ||
{ | ||
"EQ": {"message": "` + key + `test"} | ||
}, | ||
{ | ||
"IN": {"message": ["test` + key + `", "dummy"]} | ||
} | ||
] | ||
} | ||
} | ||
`, | ||
metadata: map[string]string{ | ||
"partitionKey": fmt.Sprintf("%s-struct-2", key), | ||
}, | ||
partitionOnly: true, | ||
// The same query from previous test but return only item having the same partitionKey value (%s-struct-2) given in the metadata | ||
results: []state.QueryItem{ | ||
{ | ||
Key: fmt.Sprintf("%s-struct-2", key), | ||
Data: []byte(fmt.Sprintf(`{"message":"%stest"}`, key)), | ||
}, | ||
}, | ||
}, |
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.
@berndverst I added PartitionKey as feature for doing this test; this scenario will be ok only for CosmosDB, because for the others states will return 2 items instead of 1.
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 see. Not ideal - but I can't at the moment think of a better way to do this either.
e3be222
to
6f57467
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 finally got around to merging your query operators PR.
Could you resolve the merge conflict here now and then we'll get this one merged also? :)
6f57467
to
2a7ff4d
Compare
@berndverst done! |
@luigirende I'll merge this. Can you please make sure to take ownership of this docs issue and make the docs PR? Otherwise nobody will know about this. Use |
/ok-to-test |
Components certification testCommit ref: 45f3b74 ❌ Some certification tests failedThese tests failed:
|
Complete Build MatrixThe build status is currently not updated here. Please visit the action run below directly. Commit ref: 45f3b74 |
Components conformance testCommit ref: 45f3b74 ❌ Some conformance tests failedThese tests failed:
|
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 CosmosDB conformance test is failing.
Hi @berndverst I think there has been an issue with azure tests. In fact fails also the azure postgresql tes and in this PR I haven't done any change on postgresql state.
Can you do a check or test again the PR? |
@luigirende I think this because of your other PR which is now merged, but you also must keep in mind that multiple tests might be running in parallel. Your test must work in that situation! When the test starts it uses a unique prefix for the test run. So you need to write your test such that it will only look for the results with this particular prefix. Also keep in mind you still have a conflict in |
45f3b74
to
a2dc965
Compare
@berndverst merged the conflict in |
a2dc965
to
5ca1b69
Compare
…data request for the Query Method (uniform with Set and Get). Disabling the cross partition Signed-off-by: luigirende <[email protected]>
Signed-off-by: Luigi Rende <[email protected]>
Signed-off-by: Bernd Verst <[email protected]>
Signed-off-by: Luigi Rende <[email protected]>
5ca1b69
to
a806f06
Compare
/ok-to-test |
Complete Build MatrixThe build status is currently not updated here. Please visit the action run below directly. Commit ref: c1f2bdf |
Components certification testCommit ref: c1f2bdf ❌ Some certification tests failedThese tests failed:
|
Components conformance testCommit ref: c1f2bdf ❌ Some conformance tests failedThese tests failed:
|
/ok-to-test |
Complete Build MatrixThe build status is currently not updated here. Please visit the action run below directly. Commit ref: 46a5d05 |
Components conformance testCommit ref: 46a5d05 ✅ All conformance tests passedAll tests have reported a successful status |
Components certification testCommit ref: 46a5d05 ❌ Some certification tests failedThese tests failed:
|
Opportunity to add the partitionKey field in the metadata of the Query request (how it's done in the Set and Get method).
If the user adds the partitionKey in the query method, the database before filtering all the items that belongs to the same partitionKey value, used in the request; after applies the query defined in the request. In this case the cross partition will be disabled, so the scan of the item that the database will do in the container will be only for a subset of item, improving the performance
Description
Please explain the changes you've made
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #[issue number]
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: