Skip to content
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

select DISTINCT results in "incorrect syntax near 'DISTINCT'" #311

Open
ghost opened this issue Jan 29, 2020 · 0 comments
Open

select DISTINCT results in "incorrect syntax near 'DISTINCT'" #311

ghost opened this issue Jan 29, 2020 · 0 comments

Comments

@ghost
Copy link

ghost commented Jan 29, 2020

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.<init>(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.<init>(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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants