Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: Refactors Optimistic Direct Execution to be turned on by default on .NET SDK #4225

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c5afef5
Turned on ODe by default
akotalwar Dec 21, 2023
1829fac
update subpartitioning tests to include ODE
NaluTripician Jan 2, 2024
1bac380
Updated contracts
akotalwar Jan 3, 2024
caf86c6
Merge branch 'users/akotalwar/TurnOnODEByDefault' of https://github.c…
akotalwar Jan 3, 2024
2fe5471
adds multihash test cases
NaluTripician Jan 3, 2024
f1aae84
Updated client serialization test output
akotalwar Jan 3, 2024
fa4b47f
Merge branch 'users/akotalwar/TurnOnODEByDefault' of https://github.c…
akotalwar Jan 3, 2024
492425c
Updated OffsetLimitPageSize() test
akotalwar Jan 4, 2024
255d13b
Revert changes to Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos…
akotalwar Jan 4, 2024
f4514db
Updated EndToEndTraceWriterBaselineTests.ReadManyAsync baseline test
akotalwar Jan 4, 2024
094e886
Removed account details
akotalwar Jan 5, 2024
cc1db80
Updated performance benchmark results
akotalwar Jan 5, 2024
ab69838
Merge branch 'master' into users/akotalwar/TurnOnODEByDefault
akotalwar Jan 6, 2024
4fb4163
Set enableODE to true for some of the tests
akotalwar Jan 10, 2024
badcfd0
Merge branch 'users/akotalwar/TurnOnODEByDefault' of https://github.c…
akotalwar Jan 10, 2024
eb85e34
Updated Feed token tests to test ODE and non ODE cases
akotalwar Jan 10, 2024
426f6b0
Added ODE testing for Session token regression test
akotalwar Jan 12, 2024
8f0ce41
Updated AggregateQueryTests() and CosmosMultiHashTest()
akotalwar Jan 12, 2024
e30479f
Reverted changes to OffsetLimitPageSize()
akotalwar Jan 13, 2024
a8e01e8
Added ODE testing to AggregateFunctionAsync()
akotalwar Jan 15, 2024
53ed6dc
Removed account details from baseline tests
akotalwar Jan 15, 2024
0110e90
Added assert to confirm that the right document is being returned eve…
akotalwar Jan 16, 2024
07e1a9e
Merge branch 'master' into users/akotalwar/TurnOnODEByDefault
akotalwar Jan 16, 2024
ac55208
Updated location of foreach loop for ODE
akotalwar Jan 16, 2024
2e2e35a
Merge branch 'users/akotalwar/TurnOnODEByDefault' of https://github.c…
akotalwar Jan 16, 2024
ddea7d0
Updated baselines
akotalwar Jan 17, 2024
5af47e4
Merge branch 'master' into users/akotalwar/TurnOnODEByDefault
akotalwar Jan 17, 2024
0918378
Fixed comments
akotalwar Jan 19, 2024
021cad9
Merge branch 'users/akotalwar/TurnOnODEByDefault' of https://github.c…
akotalwar Jan 19, 2024
2b068e0
Cleaned up code
akotalwar Jan 19, 2024
78ea0e4
Merge branch 'master' into users/akotalwar/TurnOnODEByDefault
akotalwar Jan 19, 2024
131112c
Fixed baselines
akotalwar Jan 19, 2024
f84c9d9
Merge branch 'users/akotalwar/TurnOnODEByDefault' of https://github.c…
akotalwar Jan 19, 2024
4ebd3a8
Updated more baselines
akotalwar Jan 19, 2024
3d3c7f7
Merge branch 'master' into users/akotalwar/TurnOnODEByDefault
akotalwar Jan 19, 2024
cd871ad
Setting QueryRequestRateTest() to not use ODE
akotalwar Jan 22, 2024
ede9b21
Merge branch 'users/akotalwar/TurnOnODEByDefault' of https://github.c…
akotalwar Jan 22, 2024
d4df81c
Merge branch 'master' into users/akotalwar/TurnOnODEByDefault
akotalwar Jan 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal static class CosmosQueryExecutionContextFactory
{
internal const string ClientDisableOptimisticDirectExecution = "clientDisableOptimisticDirectExecution";
private const string InternalPartitionKeyDefinitionProperty = "x-ms-query-partitionkey-definition";
private const string QueryInspectionPattern = @"\s+(GROUP\s+BY\s+|COUNT\s*\(|MIN\s*\(|MAX\s*\(|AVG\s*\(|SUM\s*\(|DISTINCT\s+)";
private const string QueryInspectionPattern = @"\s*(GROUP\s+BY\s+|COUNT\s*\(|MIN\s*\(|MAX\s*\(|AVG\s*\(|SUM\s*\(|DISTINCT\s+)";
private const string OptimisticDirectExecution = "OptimisticDirectExecution";
private const string Passthrough = "Passthrough";
private const string Specialized = "Specialized";
Expand Down Expand Up @@ -782,7 +782,7 @@ private static Documents.PartitionKeyDefinition GetPartitionKeyDefinition(InputP
Debug.Assert(containerQueryProperties.ResourceId != null, "CosmosQueryExecutionContextFactory Assert!", "Container ResourceId cannot be null!");

List<Documents.PartitionKeyRange> targetRanges;
if (partitionedQueryExecutionInfo != null)
if (partitionedQueryExecutionInfo != null || inputParameters.InitialFeedRange != null)
akotalwar marked this conversation as resolved.
Show resolved Hide resolved
{
targetRanges = await CosmosQueryExecutionContextFactory.GetTargetPartitionKeyRangesAsync(
cosmosQueryContext.QueryClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,7 @@ public class QueryRequestOptions : RequestOptions
/// <value>
/// Direct (optimistic) execution offers improved performance for several kinds of queries such as a single partition streaming query.
/// </value>
#if PREVIEW
public
#else
internal
#endif
bool EnableOptimisticDirectExecution { get; set; }
#if PREVIEW
= true;
#endif
public bool EnableOptimisticDirectExecution { get; set; } = true;
akotalwar marked this conversation as resolved.
Show resolved Hide resolved
akotalwar marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Gets or sets the maximum number of items that can be buffered client side during
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ JOIN (
WHERE (LENGTH(v2["FamilyName"]) > 10)
ORDER BY v2 ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand All @@ -423,7 +423,7 @@ JOIN (
WHERE ((LENGTH(v2["FamilyName"]) > 10) AND (LENGTH(v2["FamilyName"]) < 20))
ORDER BY v2 ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand All @@ -442,7 +442,7 @@ JOIN (
WHERE ((LENGTH(v2["FamilyName"]) > 10) AND (LENGTH(v2["FamilyName"]) < 20))
ORDER BY v2 ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand Down Expand Up @@ -482,7 +482,7 @@ JOIN (
WHERE (LENGTH(v2["FamilyName"]) > 10)
ORDER BY v2 ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand Down Expand Up @@ -559,7 +559,7 @@ JOIN (
WHERE (LENGTH(v2["FamilyName"]) > 10)
ORDER BY v2 ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand All @@ -578,7 +578,7 @@ JOIN (
WHERE (LENGTH(v2["FamilyName"]) > 10)
ORDER BY v2 ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand All @@ -597,7 +597,7 @@ JOIN (
WHERE (LENGTH(v2["FamilyName"]) > 10)
ORDER BY v2["GivenName"]["Length"] ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand All @@ -616,7 +616,7 @@ JOIN (
WHERE (LENGTH(v2["FamilyName"]) > 10)
ORDER BY v2["GivenName"]["Length"] ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand All @@ -635,7 +635,7 @@ JOIN (
WHERE (LENGTH(v2["FamilyName"]) > 10)
ORDER BY v2 ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand All @@ -654,7 +654,7 @@ JOIN (
WHERE (LENGTH(v2["FamilyName"]) > 10)
ORDER BY v2 ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand Down Expand Up @@ -689,7 +689,7 @@ JOIN (
JOIN v0 IN root["Parents"]) AS v2
ORDER BY v2["FamilyName"] ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand All @@ -707,7 +707,7 @@ JOIN (
JOIN v0 IN root["Parents"]) AS v2
ORDER BY v2["FamilyName"] ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand Down Expand Up @@ -773,7 +773,7 @@ JOIN (
JOIN p0 IN root["Parents"]) AS v1
ORDER BY v1 ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand All @@ -792,7 +792,7 @@ JOIN (
WHERE (LENGTH(v1) > 10)
ORDER BY v1 ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ JOIN (
SELECT VALUE root
FROM root
ORDER BY root["FamilyId"] ASC, root["FamilyId"] ASC]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["The order by query does not have a corresponding composite index that it can be served from."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand All @@ -132,7 +132,7 @@ ORDER BY root["FamilyId"] ASC, root["FamilyId"] ASC]]></SqlQuery>
SELECT VALUE root
FROM root
ORDER BY root["FamilyId"] ASC, root["FamilyId"] DESC]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["The order by query does not have a corresponding composite index that it can be served from."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand Down Expand Up @@ -388,7 +388,6 @@ FROM (
JOIN c0 IN root["Children"]) AS v1) AS r1
ORDER BY r1["FamilyId"] ASC, r1["FamilyNumber"] ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Underlying object does not have an '_rid' or '__sys_rid' field.]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand Down Expand Up @@ -435,7 +434,6 @@ FROM (
WHERE (p0["GivenName"]["Length"] > 5)) AS v0) AS r0
ORDER BY r0["FamilyId"] ASC, r0["FamilyNumber"] ASC
]]></SqlQuery>
<ErrorMessage><![CDATA[Underlying object does not have an '_rid' or '__sys_rid' field.]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand Down Expand Up @@ -586,7 +584,7 @@ FROM root
JOIN f0 IN root["Records"]["Transactions"]
WHERE (ARRAY_LENGTH(root["Children"]) > 0)
ORDER BY f0["Type"] ASC, f0["Amount"] ASC]]></SqlQuery>
<ErrorMessage><![CDATA[Status Code: BadRequest]]></ErrorMessage>
<ErrorMessage><![CDATA[Status Code: BadRequest","message":"Message: {"Errors":["Order-by over correlated collections is not supported."]}rn]]></ErrorMessage>
</Output>
</Result>
<Result>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,7 @@ public async Task QueryRequestRateTest(bool directMode)
{
MaxItemCount = 1,
MaxConcurrency = 1,
#if PREVIEW
EnableOptimisticDirectExecution = false
#endif
EnableOptimisticDirectExecution = false,
}))
{
while (feedIterator.HasMoreResults)
Expand Down Expand Up @@ -271,9 +269,7 @@ public async Task QueryRequestRateTest(bool directMode)
{
MaxItemCount = 1,
MaxConcurrency = 1,
#if PREVIEW
EnableOptimisticDirectExecution = false
#endif
EnableOptimisticDirectExecution = false,
});

// First request should be a success
Expand Down Expand Up @@ -803,7 +799,6 @@ public async Task TesOdeTokenCompatibilityWithNonOdePipeline()
QueryRequestOptions queryRequestOptions = new QueryRequestOptions
{
MaxItemCount = 50,
EnableOptimisticDirectExecution = true
};

FeedIteratorInternal feedIterator =
Expand Down Expand Up @@ -833,7 +828,7 @@ public async Task TesOdeTokenCompatibilityWithNonOdePipeline()
responseMessage = await feedIteratorNew.ReadNextAsync(CancellationToken.None);
}

string expectedErrorMessage = "The continuation token supplied requires the Optimistic Direct Execution flag to be enabled in QueryRequestOptions for the query execution to resume. ";
string expectedErrorMessage = "Execution of this query using the supplied continuation token requires EnableOptimisticDirectExecution to be set in QueryRequestOptions. ";
Assert.IsTrue(responseMessage.CosmosException.ToString().Contains(expectedErrorMessage));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ public async Task QueryPlanRetryTimeoutTestAsync()

QueryRequestOptions requestOptions = new QueryRequestOptions()
{
#if PREVIEW
// ODE set to false in this scenario as using ODE could cause the query plan to not get invoked.
EnableOptimisticDirectExecution = false
akotalwar marked this conversation as resolved.
Show resolved Hide resolved
#endif
};

using FeedIterator<JObject> iterator = gatewayQueryPlanContainer.GetItemQueryIterator<JObject>("select * From T order by T.status", requestOptions: requestOptions);
Expand Down