question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Combination of Distinct and Offset does not work in v3.14.0

See original GitHub issue

Describe the bug After upgrading Cosmos DB SDK to the latest version, one of my queries stopped returning the data and now also causing an infinite loop. Removing Distinct or the OFFSET 0 LIMIT 15 part from the query makes SDK return the data again. I also tried versions [3.6.0 - 3.13.0] and they worked fine.

To Reproduce

var result = new List<CosmosDto>();
var query = new QueryDefinition("SELECT distinct c.Version, c.MetaData FROM Collection c ORDER BY c._ts DESC OFFSET 0 LIMIT 15");
var iterator = container.GetItemQueryIterator<CosmosDto>(query, requestOptions: requestOptions);
while (iterator.HasMoreResults)
{
    var moreResults = await iterator.ReadNextAsync();
    result.AddRange(moreResults.Resource);
}

Expected behavior ReadNextAsync() should return the requested data back. HasMoreResults should return false when SDK fails internally for whatever reason.

Actual behavior ReadNextAsync() returns OK status but Resource value is an empty array. HasMoreResults always stays true. I validated the query through Data Explorer in Azure and that returns all the data correctly.

Environment summary SDK Version: 3.14.0/3.15.0-preview OS Version: Windows

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
bchong95commented, Mar 3, 2021

In general the empty pages are to satisfy your sort order on _ts. The client needs to grab one page of records from each partition and then sort the results client side. Until then it’s forced to pass back empty pages to give you a preemption point for the query. On the 5th page we finally have one page from each of the 4 partitions and we can serve the ORDER BY condition and that’s when we return you the 5 documents. You can look at the CosmosDiagnostics to get a better sense of this.

0reactions
msftbot[bot]commented, Dec 15, 2021

Closing due to in-activity, pease feel free to re-open.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ruby on rails - offset not selecting distinct values
Meaning it will update the updated_at column of the parent object if the child object changes (i.e. a new movie image is being...
Read more >
Package 'data.table'
j. When with=TRUE (default), j is evaluated within the frame of the data.table;. i.e., it sees column names as if they are variables....
Read more >
Ecto.Query — Ecto v3.10.3
Settings View Source Ecto.Query (Ecto v3.10.3). Provides the Query DSL. Queries are used to retrieve and manipulate data from a repository (see Ecto.Repo...
Read more >
API Reference — more-itertools 10.1.0 documentation
Only adjacent items are grouped together, so if you don't want any duplicate groups, you should sort the iterable by the key function....
Read more >
TS 125 302 - V3.14.0
Nevertheless, at a given point of time, not all combinations may be submitted to layer 1 but only a subset, the Transport Format...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found