You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Azure Cosmos DB state store and the QueryStateAsync() method. I want to get all of my data and used var query = "{\"filter\": {}}", but I run into an exception ("state store statestorecosmos query failed: context canceled") if my database has more than 999 rows. I then tried to use pagination, but I'm having unexpected behaviors with the returned continuation token.
Expected Behavior
If I have let's say 500 records in my container. I request 100 records. The token returned by QueryStateAsync() should allow me to read the next 100 records, and so on.
Actual Behavior
The token returned by QueryStateAsync() after retrieving the first 100 records is empty, so if I supply that in the query I get the same exact 100 records as before. I can't continue reading the data.
Steps to Reproduce the Problem
Using the .NET SDK:
var query = "{\"filter\": {}, \"page\": {\"limit\": 100}}";
var employeesResponse = await _daprClient.QueryStateAsync<Employee>(STORE_NAME, query, cancellationToken: cancellation);
// employeesResponse contains the first 100 records as expected
var paginationToken = employeesResponse.Token;
// Have to modify the token to escape the quotes first
...
query = $"{{\"filter\": {{}}, \"page\": {{\"limit\": 100, \"token\": {paginationToken}}}}}";
employeesResponse = await _daprClient.QueryStateAsync<Employee>(STORE_NAME, query, cancellationToken: cancellation);
// Should return the next 100 records, but doesn't because the token is empty. It returns the same 100 records returned previously
Or going directly to the API to just get 1 record at a time using this PowerShell script:
You'll notice that the key in the result of the first query is the same as the one from the second query, so it's returning the same record.
Additional Remarks
From the component code it looks like there is a bug, the limit is never forwarded to Cosmos DB. It is only used to return a subset of the result. Therefore the component is actually reading the default page size. The token returned by the component, if returned, causes unexpected behaviors.
I'm using Dapr version 1.13.0.
Thanks!
The text was updated successfully, but these errors were encountered:
Query API is Alpha and unsupported. We are not currently planning to advance the Query API due to several significant design flaws, creating inconsistencies in experience across components and also a maintenance and support nightmare.
Additionally, the CosmosDB Go SDK we are using does not have native Query support and our attempt to implement this is extremely limited and error prone. Certain features of the Dapr Query API interface cannot currently be supported by our Cosmos DB implementation.
The Dotnet CosmosDB SDK as a lot of features which the Go SDK does not have. We have spoken to the CosmosDB team and the Azure SDK for Go team extensively, but not much can be done here until the CosmosDB team expands the capabilities of other SDKs.
Please consider using a Cosmos DB SDK with Query support directly for querying.
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.
Hi,
I'm using Azure Cosmos DB state store and the QueryStateAsync() method. I want to get all of my data and used
var query = "{\"filter\": {}}"
, but I run into an exception ("state store statestorecosmos query failed: context canceled"
) if my database has more than 999 rows. I then tried to use pagination, but I'm having unexpected behaviors with the returned continuation token.Expected Behavior
If I have let's say 500 records in my container. I request 100 records. The token returned by QueryStateAsync() should allow me to read the next 100 records, and so on.
Actual Behavior
The token returned by QueryStateAsync() after retrieving the first 100 records is empty, so if I supply that in the query I get the same exact 100 records as before. I can't continue reading the data.
Steps to Reproduce the Problem
Using the .NET SDK:
Or going directly to the API to just get 1 record at a time using this PowerShell script:
You'll notice that the key in the result of the first query is the same as the one from the second query, so it's returning the same record.
Additional Remarks
From the component code it looks like there is a bug, the limit is never forwarded to Cosmos DB. It is only used to return a subset of the result. Therefore the component is actually reading the default page size. The token returned by the component, if returned, causes unexpected behaviors.
I'm using Dapr version
1.13.0
.Thanks!
The text was updated successfully, but these errors were encountered: