Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private static async Task<TryCatch<IQueryPipelineStage>> TryCreateCoreContextAsy
// If the query would go to gateway, but we have a partition key,
// then try seeing if we can execute as a passthrough using client side only logic.
// This is to short circuit the need to go to the gateway to get the query plan.
if (cosmosQueryContext.QueryClient.ByPassQueryParsing()
if (cosmosQueryContext.QueryClient.BypassQueryParsing()
&& inputParameters.PartitionKey.HasValue)
{
bool parsed;
Expand Down Expand Up @@ -586,7 +586,7 @@ private static async Task<PartitionedQueryExecutionInfo> GetPartitionedQueryExec
CancellationToken cancellationToken)
{
PartitionedQueryExecutionInfo partitionedQueryExecutionInfo;
if (cosmosQueryContext.QueryClient.ByPassQueryParsing())
if (cosmosQueryContext.QueryClient.BypassQueryParsing())
{
// For non-Windows platforms(like Linux and OSX) in .NET Core SDK, we cannot use ServiceInterop, so need to bypass in that case.
// We are also now bypassing this for 32 bit host process running even on Windows as there are many 32 bit apps that will not work without this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public abstract Task<PartitionedQueryExecutionInfo> ExecuteQueryPlanRequestAsync
bool forceRefresh,
ITrace trace);

public abstract bool ByPassQueryParsing();
public abstract bool BypassQueryParsing();

public abstract Task ForceRefreshCollectionCacheAsync(
string collectionLink,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public override async Task<List<PartitionKeyRange>> GetTargetPartitionKeyRangesA
}
}

public override bool ByPassQueryParsing()
public override bool BypassQueryParsing()
{
return CustomTypeExtensions.ByPassQueryParsing();
}
Expand Down
7 changes: 1 addition & 6 deletions Microsoft.Azure.Cosmos/src/SqlObjects/SqlPropertyName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ sealed class SqlPropertyName : SqlObject

private SqlPropertyName(string value)
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException($"{nameof(value)} must not be null, empty, or whitespace.");
}

this.Value = value;
this.Value = value ?? throw new ArgumentNullException(nameof(value));
}

public string Value { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public DisableServiceInterop(
{
}

public override bool ByPassQueryParsing()
public override bool BypassQueryParsing()
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Microsoft.Azure.Cosmos.EmulatorTests.Query
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -14,9 +15,28 @@ public sealed class BypassQueryParsingTests : QueryTestsBase
public async Task TestBypassQueryParsingWithNonePartitionKey()
{
int documentCount = 400;
QueryRequestOptions feedOptions = new QueryRequestOptions { PartitionKey = PartitionKey.None };

string query = "SELECT VALUE r.numberField FROM r";
IReadOnlyList<int> expected = Enumerable.Range(0, documentCount).ToList();
IReadOnlyList<string> expectedOutput = Enumerable.Range(0, documentCount).Select(i => i.ToString()).ToList();

await this.ValidateQueryBypassWithNonePartitionKey(documentCount, query, expectedOutput);
}

[TestMethod]
[TestCategory("Query")]
public async Task TestBypassQueryParsingWithNonePartitionKeyEmptyPropertyName()
{
int documentCount = 400;

string query = @"SELECT VALUE { """" : r.numberField } FROM r";
IReadOnlyList<string> expectedOutput = Enumerable.Range(0, documentCount).Select(i => String.Format("{{\"\":{0}}}", i)).ToList();

await this.ValidateQueryBypassWithNonePartitionKey(documentCount, query, expectedOutput);
}

private async Task ValidateQueryBypassWithNonePartitionKey(int documentCount, string query, IReadOnlyList<string> expectedOutput)
{
QueryRequestOptions feedOptions = new QueryRequestOptions { PartitionKey = PartitionKey.None };

async Task ImplementationAsync(Container container, IReadOnlyList<CosmosObject> documents)
{
Expand All @@ -34,9 +54,9 @@ async Task ImplementationAsync(Container container, IReadOnlyList<CosmosObject>
cosmosQueryClientCore);

List<CosmosElement> items = await RunQueryAsync(containerWithBypassParsing, query, feedOptions);
int[] actual = items.Cast<CosmosNumber>().Select(x => (int)Number64.ToLong(x.Value)).ToArray();
string[] actualOutput = items.Select(x => x.ToString()).ToArray();

Assert.IsTrue(expected.SequenceEqual(actual));
Assert.IsTrue(expectedOutput.SequenceEqual(actualOutput));
}

IReadOnlyList<string> documents = CreateDocuments(documentCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public MockCosmosQueryClient(

public int QueryPlanCalls { get; private set; }

public override bool ByPassQueryParsing()
public override bool BypassQueryParsing()
{
return this.forceQueryPlanGatewayElseServiceInterop;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ internal class TestCosmosQueryClient : CosmosQueryClient
{
public override Action<IQueryable> OnExecuteScalarQueryCallback => throw new NotImplementedException();

public override bool ByPassQueryParsing()
public override bool BypassQueryParsing()
{
return false;
}
Expand Down