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.

Cross Partition Order By Failing with _rid not defined exception

See original GitHub issue

I am hitting the exception thrown at this line:

https://github.com/Azure/azure-cosmos-dotnet-v3/blob/6b1fa035cdb50201aa7483cc3774eb0b521e8a47/Microsoft.Azure.Cosmos/src/Query/Core/Pipeline/CrossPartition/OrderBy/OrderByQueryResult.cs#L58

When I execute this query:

SELECT * FROM (SELECT VALUE d.item FROM d WHERE d.tenant = "xtenant" AND d.store = "xstore" AND d.kind = "xkind" AND d.container = "xcontainer" AND d.type = "xtype") c ORDER BY c.CreatedDateTime

Underlying object does not have an ‘_rid’ or ‘__sys_rid’ field.’

   at Microsoft.Azure.Cosmos.Query.Core.Pipeline.CrossPartition.OrderBy.OrderByQueryResult.get_Rid()
   at Microsoft.Azure.Cosmos.Query.Core.Pipeline.CrossPartition.OrderBy.OrderByCrossPartitionQueryPipelineStage.MoveNextAsync_DrainPageAsync(ITrace trace)
   at Microsoft.Azure.Cosmos.Query.Core.Pipeline.CrossPartition.OrderBy.OrderByCrossPartitionQueryPipelineStage.MoveNextAsync(ITrace trace)
   at Microsoft.Azure.Cosmos.Query.Core.Pipeline.SkipEmptyPageQueryPipelineStage.<MoveNextAsync>d__13.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Cosmos.Query.Core.Pipeline.LazyQueryPipelineStage.<MoveNextAsync>d__8.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Cosmos.Query.Core.Pipeline.NameCacheStaleRetryQueryPipelineStage.<MoveNextAsync>d__10.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Cosmos.Query.Core.Pipeline.CatchAllQueryPipelineStage.<MoveNextAsync>d__1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Cosmos.Query.QueryIterator.<ReadNextAsync>d__14.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Cosmos.FeedIteratorCore`1.<ReadNextAsync>d__8.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Cosmos.ClientContextCore.<RunWithDiagnosticsHelperAsync>d__39`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Cosmos.ClientContextCore.<OperationHelperWithRootTraceAsync>d__30`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()

Can someone please explain why that is and what I can do to resolve it? This same query works fine in the Azure Cosmos DB portal data explorer.

Thank you.

Issue Analytics

  • State:open
  • Created 9 months ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
neildshcommented, Dec 19, 2022

Thanks for reporting this @krispenner . We will take a look and try to see what is happening.

0reactions
krispennercommented, Aug 16, 2023

@neildsh any update?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cosmos db REST API order by with partitioning
If I disable cross partition query then I get: "Cross partition query is required but disabled. Please set x-ms-documentdb-query- ...
Read more >
Error when using OrderBy on field with possible NULL ...
Unfortunately, this query fails with: Unhandled Exception: System.NotSupportedException: Cannot execute cross partition order-by queries on mix types. Consider ...
Read more >
Querying Azure Cosmos DB resources using the REST API
Learn how to query Azure Cosmos DB resources using REST API. Request and response headers, body, status codes and examples.
Read more >
Common SQL syntax errors and how to resolve them
In this article, we are going to describe some of the most common SQL syntax errors, and explains how you can resolve these...
Read more >
Problem writing to Azure Cosmos DB - FME Community
Cosmos DB (DocumentDB) Reader: Request failed with HTTP status 400. The message from the server is: 'Cross partition query is required but ...
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