[BUG] azure-cosmos 3.4.0, 3.5.0, 3.6.0 QueryPlan doesn't support DISTINCT
See original GitHub issueDescribe the bug We’re attempting to upgrade to use version 3.4.0 via the Spring Cosmos 2.2.1.M1 version and ran into what seems to be a bug. Specifically we can no longer execute “distinct” queries.
Exception or Stack Trace
We receive the following from the query plan retriever.
com.azure.data.cosmos.CosmosClientException: Gateway Failed to Retrieve Query Plan: Query contains 1 or more unsupported features. Upgrade your SDK to a version that does support the requested features: Query contained Distinct, which the calling client does not support. ActivityId: f569ddf6-e3e0-445a-9546-6931f17a4033, Microsoft.Azure.Documents.Common/2.7.0, StatusCode: BadRequest
It seems the client is not including the “distinct” query feature in the query plan header. I’m not sure if this intentional. If so, how do we execute “distinct” queries?
Code Snippet
Here is the code that used to work but is failing with 3.4.0.
val query = SqlQuerySpec(
"SELECT DISTINCT r.deviceId FROM root r WHERE $expression",
parameterCollection
)
val options = FeedOptions().apply { enableCrossPartitionQuery(true) }
return cosmosClient
.getDatabase(cosmosDBConfig.database)
.getContainer(DocumentCollectionNames.sensor)
.queryItems(query, options)
.collectResults()
.map {
objectMapper.readValue<JsonNode>(it.toJson()).get("deviceId").toString()
}
Expected behavior
3.4.0 Should continue to support “Distinct” queries just like 3.3.x
Setup (please complete the following information):
- OS: macOS
- IDE : IntelliJ
- Version of the Library used : 3.4.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:19 (6 by maintainers)
Any news about this issue? Also the version 3.7.0 is affected by this bug
Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment.