Skip to content

Commit 3895cd4

Browse files
PaulChengealsur
andauthored
[Internal] Query: Adds support of __sys_rid to order by query result (#3271)
* order by query result to support __sys_rid * update unit tests Co-authored-by: Matias Quaranta <ealsur@users.noreply.github.com>
1 parent be8814f commit 3895cd4

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Microsoft.Azure.Cosmos/src/Query/Core/Pipeline/CrossPartition/OrderBy/OrderByQueryResult.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,18 @@ public string Rid
5050
{
5151
get
5252
{
53+
// cassandra row uses __sys_rid as opposed to _rid
5354
if (!this.cosmosObject.TryGetValue("_rid", out CosmosElement cosmosElement))
5455
{
55-
throw new InvalidOperationException($"Underlying object does not have an '_rid' field.");
56+
if (!this.cosmosObject.TryGetValue("__sys_rid", out cosmosElement))
57+
{
58+
throw new InvalidOperationException($"Underlying object does not have an '_rid' or '__sys_rid' field.");
59+
}
5660
}
5761

5862
if (!(cosmosElement is CosmosString cosmosString))
5963
{
60-
throw new InvalidOperationException($"'_rid' field was not a string.");
64+
throw new InvalidOperationException($"'_rid' or '__sys_rid' field was not a string.");
6165
}
6266

6367
return cosmosString.Value;

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/LinqGeneralBaselineTests.TestThenByTranslation.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ FROM (
388388
JOIN c0 IN root["Children"]) AS v1) AS r1
389389
ORDER BY r1["FamilyId"] ASC, r1["FamilyNumber"] ASC
390390
]]></SqlQuery>
391-
<ErrorMessage><![CDATA[Underlying object does not have an '_rid' field.]]></ErrorMessage>
391+
<ErrorMessage><![CDATA[Underlying object does not have an '_rid' or '__sys_rid' field.]]></ErrorMessage>
392392
</Output>
393393
</Result>
394394
<Result>
@@ -435,7 +435,7 @@ FROM (
435435
WHERE (p0["GivenName"]["Length"] > 5)) AS v0) AS r0
436436
ORDER BY r0["FamilyId"] ASC, r0["FamilyNumber"] ASC
437437
]]></SqlQuery>
438-
<ErrorMessage><![CDATA[Underlying object does not have an '_rid' field.]]></ErrorMessage>
438+
<ErrorMessage><![CDATA[Underlying object does not have an '_rid' or '__sys_rid' field.]]></ErrorMessage>
439439
</Output>
440440
</Result>
441441
<Result>

0 commit comments

Comments
 (0)