Closed marleypowell closed 1 year ago
Query API is Alpha and will not be made stable.
Because Dapr by default manages the partition key of entities written we only support Cross Partition Queries. And Cross Partition queries are inherently very limited. The article you linked to contains those limitations.
The only way to implement Order By
would be to read the entirety of the collection into memory and then sort. That's not a good idea however, so it's simply not supported.
We are considering implementing a new DocumentStore building block in the future which would support rich query capabilities. CosmosDB would receive a first class implementation at that time - this will be a completely separate implementation from the current Dapr Query API which will be deprecated at that time. That building block is also not intended to be compatible with any data written via the state store component - though it may be possible to query that data.
Expected Behavior
When using CosmosDB as the state store I would expect to be able to make a query with sorting.
Actual Behavior
When using a sort query CosmosDB errors:
This might be a CosmosDB limitation? https://learn.microsoft.com/en-us/rest/api/cosmos-db/querying-cosmosdb-resources-using-the-rest-api#queries-that-cannot-be-served-by-gateway
TOP
is listed on there but I can see that it's being handled by the sdk rather than CosmosDB which would be why that works.Ordering though still tries to use the CosmosDB client:
Steps to Reproduce the Problem
Use any sort query when using CosmosDB as a state store.