Azure / azure-cosmosdb-java

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

StringPartitionKeyComponent limits the key length to 100 chars #63

Closed chetanmeh closed 6 years ago

chetanmeh commented 6 years ago

StringPartitionKeyComponent truncates the key to 100 chars.

https://github.com/Azure/azure-cosmosdb-java/blob/17937b1d230ab78202cde3380dc8be83ff9cd43b/sdk/src/main/java/com/microsoft/azure/cosmosdb/internal/routing/StringPartitionKeyComponent.java#L34

Per docs the maximum length for id field is 255 chars. However I was not able to find any documented limit for partition key. Closest reference found here mentions

The length of RowKey is 255 bytes and the length of PartitionKey is 1 KB.

Can this limit in StringPartitionKeyComponent be set to 255 at least? Due to current truncation I get error PartitionKey extracted from document doesn't match the one specified in the header as the id field in document being added has length say 120 chars while one passed in header is truncated to 100.

moderakh commented 6 years ago

@chetanmeh thanks for reporting this. We have a fix for this, which should get released along some other improvements in a week or so. We are code complete, just final review, testing.

chetanmeh commented 6 years ago

@moderakh Good to know that its under fix. Just to unblock myself for now would it be fine to just bump the limit locally assuming the limit for PartitionKey is >= 255 or there is more to this issue

moderakh commented 6 years ago

@chetanmeh no. that won't work.

chetanmeh commented 6 years ago

Thanks for confirming. Would then look for next release

moderakh commented 6 years ago

addressed in 2.1.0.

added unit test: https://github.com/Azure/azure-cosmosdb-java/blob/master/sdk/src/test/java/com/microsoft/azure/cosmosdb/rx/DocumentCrudTest.java#L99-L115

chetanmeh commented 6 years ago

@moderakh Should the test create key with length 255 as thats the max limit. So far keys upto 100 work as expected as that was the earlier limit in StringPartitionKeyComponent

chetanmeh commented 6 years ago

Ignore the previous comment. Now see that test case was building with 2-3 chars per iteration. Also looks like 255 limit is only for id. For partition key the limit looks much higher (probably 1 KB).

So it works fine now !!