Azure / Azure/azure-cosmosdb-java
select DISTINCT results in "incorrect syntax near 'DISTINCT'"
- Dominant language
- Java
- Stars
- 59
- Forks
- 68
- PR merge metrics
- No merged PRs in 30d
Description
The statement
`SELECT DISTINCT c.machine_id FROM c`
(WHERE clause omitted for brevity)
works perfectly fine in the cosmosdb data explorer
Same statement issued via Java SDK
```
DocumentClient documentClient = new DocumentClient(endPoint, masterKey, ConnectionPolicy.GetDefault(), ConsistencyLevel.Session);
FeedOptions feedOptions = new FeedOptions();
feedOptions.setEnableCrossPartitionQuery(true);
documentClient.queryDocuments(
"dbs/data/colls/someCollection",
"SELECT DISTINCT c.machine_id FROM c", feedOptions)
```
results in
```
java.lang.IllegalArgumentException: {"errors":[{"severity":"Error","location":{"start":7,"end":15},"code":"SC1001","message":"Syntax error, incorrect syntax near 'DISTINCT'."}]}
at com.microsoft.azure.documentdb.internal.ServiceJNIWrapper.throwIfFailed(ServiceJNIWrapper.java:69) ~[azure-documentdb-2.4.6.jar:na]
at com.microsoft.azure.documentdb.internal.ServiceJNIWrapper.getSerializedPartitionKeyRangesFromQuery(ServiceJNIWrapper.java:238) ~[azure-documentdb-2.4.6.jar:na]
at com.microsoft.azure.documentdb.internal.ServiceJNIWrapper.getPartitionKeyRangesFromQuery(ServiceJNIWrapper.java:255) ~[azure-documentdb-2.4.6.jar:na]
at com.microsoft.azure.documentdb.internal.query.QueryPartitionProvider.getPartitionQueryExcecutionInfo(QueryPartitionProvider.java:50) ~[azure-documentdb-2.4.6.jar:na]
at com.microsoft.azure.documentdb.internal.query.ProxyQueryExecutionContext.(ProxyQueryExecutionContext.java:52) ~[azure-documentdb-2.4.6.jar:na]
at com.microsoft.azure.documentdb.internal.query.QueryExecutionContextFactory.createQueryExecutionContext(QueryExecutionContextFactory.java:23) ~[azure-documentdb-2.4.6.jar:na]
at com.microsoft.azure.documentdb.QueryIterable.createQueryExecutionContext(QueryIterable.java:70) ~[azure-documentdb-2.4.6.jar:na]
at com.microsoft.azure.documentdb.QueryIterable.reset(QueryIterable.java:115) ~[azure-documentdb-2.4.6.jar:na]
at com.microsoft.azure.documentdb.QueryIterable.(QueryIterable.java:57) ~[azure-documentdb-2.4.6.jar:na]
at com.microsoft.azure.documentdb.DocumentClient.queryDocuments(DocumentClient.java:1168) ~[azure-documentdb-2.4.6.jar:na]
at com.microsoft.azure.documentdb.DocumentClient.queryDocuments(DocumentClient.java:1127) ~[azure-documentdb-2.4.6.jar:na]
at com.microsoft.azure.documentdb.DocumentClient.queryDocuments(DocumentClient.java:1106) ~[azure-documentdb-2.4.6.jar:na]
```
**Environment summary**
Windows 10
OpenJDK 11
Spring-Boot 2.2.2
com.microsoft.azure:azure-documentdb:2.4.6
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.