Azure / azure-cosmosdb-java

Java Async SDK for SQL API of Azure Cosmos DB
MIT License
54 stars 61 forks source link

Distinct query has a serialisation issue #159

Closed kaustubhpriye closed 3 years ago

kaustubhpriye commented 5 years ago

When using a distinct query for a field foo_id, serialisation is failing with error Caused by: java.lang.ClassCastException: com.fasterxml.jackson.databind.node.TextNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode

select DISTINCT VALUE c.foo_id from c

This should have returned list of string, but fails with error. Error happens when JsonSerializable tries to call fromJson, in fromJson method, the JsonNode is downcast to ObjectNode, while actually the instance is of type TextNode . ObjectMapper is working properly.

https://github.com/Azure/azure-cosmosdb-java/blob/81a56e9506827e647253b1b6ae39f95a7aee37a3/commons/src/main/java/com/microsoft/azure/cosmosdb/JsonSerializable.java#L492

christopheranderson commented 5 years ago

@mbhaskar take a look when you get a chance. I think your PR might handle this already.

christopheranderson commented 5 years ago

@mbhaskar - can you take a look with the new Distinct changes if this is addressed?

mbhaskar commented 4 years ago

This will be handled in: https://github.com/Azure/azure-sdk-for-java/issues/6296

MrBuddyCasino commented 4 years ago

I'm just hitting this too, is there a workaround? Maybe encapsulating the DISTINCT VALUE result in something?

mbhaskar commented 4 years ago

This issue is fixed in V4. https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/cosmos/azure-cosmos/CHANGELOG.md