Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4534883
Raising version to 22-preview
kirankumarkolli Apr 4, 2019
bccf1b6
Merge master into release (CF Pull internal API) (#115)
kirankumarkolli Apr 9, 2019
d09330c
Merge remote-tracking branch 'origin/release' into users/kirankk/3.0.…
kirankumarkolli Apr 30, 2019
bd3cc82
Merge remote-tracking branch 'origin/master' into users/kirankk/3.0.0…
kirankumarkolli Apr 30, 2019
2c314dd
Merge branch 'users/kirankk/3.0.0.10_release' into release
kirankumarkolli May 1, 2019
49a3c90
fix bugs
May 4, 2019
2e12e14
Fixing signing issue
kirankumarkolli May 5, 2019
630c378
Hot fixes for CosmosSerializationOptions and query partition key issu…
j82w May 9, 2019
a41397e
added new system strings (#210)
bchong95 May 9, 2019
867ea1d
Ignoring TestLazyIndexAllTerms (#211)
kirankumarkolli May 9, 2019
dfbbcec
PartitionedCRUDTest ignored (#217)
kirankumarkolli May 9, 2019
7f9ee4b
Exception-less Streaming API for non-existing NP container scenarios …
kirankumarkolli May 10, 2019
5e3456c
SDK version to 3.0.0.11-preview and Direct dependency to 3.0.0.27-pre…
kirankumarkolli May 10, 2019
2f01f88
Cherry pick 15a9e26ceac8a78878c2e150edf5b1bbbb3af159 into 3.0.0.11_pr…
May 10, 2019
df44372
Revert "Fixing samples build break (#236)"
kirankumarkolli May 10, 2019
7013c5b
Force samples to Nuget.org only
kirankumarkolli May 10, 2019
21989bc
Merge branch 'master' of https://github.com/Azure/azure-cosmos-dotnet-v3
kirankumarkolli May 10, 2019
a678369
Fixes for query pipeline
kirankumarkolli May 11, 2019
da5ee56
Some more fixes
kirankumarkolli May 11, 2019
a4b0dfd
Np tests and quarantine open-partition tests
kirankumarkolli May 11, 2019
db78360
small correction
kirankumarkolli May 11, 2019
c3a768d
Direct contract test pruning
kirankumarkolli May 12, 2019
b239267
Few test fixes
kirankumarkolli May 12, 2019
a784a02
Bug fix for paramaterised queries
kirankumarkolli May 12, 2019
51693ad
Including NP query tests
kirankumarkolli May 12, 2019
ed4f5fb
One more test fix
kirankumarkolli May 12, 2019
cec1fdd
Fix for MixedModeTypoes unit test
kirankumarkolli May 12, 2019
3219d71
MixedMode multi-targeting tests clean.
kirankumarkolli May 12, 2019
b26ee0c
Enabling Distinct and TopOrderBy for NP.
kirankumarkolli May 12, 2019
2ed419b
Quarantine TestQueryCrossPartitionAggregateFunctionsWithMixedTypes
kirankumarkolli May 12, 2019
025d281
Merge branch 'master' of https://github.com/Azure/azure-cosmos-dotnet-v3
kirankumarkolli May 12, 2019
1a7c800
Porting release 3.0.0.11-preview changes into master
kirankumarkolli May 12, 2019
ba21625
Test fixes.
kirankumarkolli May 12, 2019
1ae2680
Merge branch 'master' into users/kirankk/3.0.0.11-preview-merge
kirankumarkolli May 12, 2019
77c1e67
BadRequestException fixes
kirankumarkolli May 12, 2019
0be1348
Owner attribute removed
kirankumarkolli May 12, 2019
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
4 changes: 4 additions & 0 deletions Microsoft.Azure.Cosmos/src/CosmosClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ static CosmosClient()
{
HttpConstants.Versions.CurrentVersion = HttpConstants.Versions.v2018_12_31;
HttpConstants.Versions.CurrentVersionUTF8 = Encoding.UTF8.GetBytes(HttpConstants.Versions.CurrentVersion);

// V3 always assumes assemblies exists
// Shall revisit on feedback
ServiceInteropWrapper.AssembliesExist = new Lazy<bool>(() => true);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Microsoft.Azure.Cosmos/src/Microsoft.Azure.Cosmos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<NeutralLanguage>en-US</NeutralLanguage>
<ClientVersion>3.0.0.12-preview</ClientVersion>
<DirectVersion>3.0.0.27-preview</DirectVersion>
<DirectVersion>3.0.0.28-preview</DirectVersion>
<Version Condition=" '$(IsNightly)' == '1' ">$(ClientVersion)-nightly$(CurrentDate)</Version>
<Version Condition=" '$(IsNightly)' == '0' Or '$(IsNightly)' == '' ">$(ClientVersion)</Version>
<FileVersion>$(VersionPrefix)</FileVersion>
Expand Down Expand Up @@ -61,5 +61,5 @@
<PropertyGroup>
<DefineConstants>$(DefineConstants);DOCDBCLIENT;NETSTANDARD20</DefineConstants>
<DefineConstants Condition=" '$(SignAssembly)' == 'true' ">$(DefineConstants);SignAssembly</DefineConstants>
</PropertyGroup>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Microsoft.Azure.Cosmos.Query
using Microsoft.Azure.Cosmos.Internal;
using Microsoft.Azure.Documents;
using Microsoft.Azure.Cosmos.CosmosElements;
using System.Net;

/// <summary>
/// CosmosOrderByItemQueryExecutionContext is a concrete implementation for CrossPartitionQueryExecutionContext.
Expand Down Expand Up @@ -385,15 +386,15 @@ private OrderByContinuationToken[] ValidateAndExtractContinuationToken(
if (suppliedOrderByContinuationTokens.Length == 0)
{
this.TraceWarning($"Order by continuation token can not be empty: {requestContinuation}.");
throw new BadRequestException(RMResources.InvalidContinuationToken);
throw new CosmosException(HttpStatusCode.BadRequest, RMResources.InvalidContinuationToken);
}

foreach (OrderByContinuationToken suppliedOrderByContinuationToken in suppliedOrderByContinuationTokens)
{
if (suppliedOrderByContinuationToken.OrderByItems.Count != sortOrders.Length)
{
this.TraceWarning($"Invalid order-by items in continuation token {requestContinuation} for OrderBy~Context.");
throw new BadRequestException(RMResources.InvalidContinuationToken);
throw new CosmosException(HttpStatusCode.BadRequest, RMResources.InvalidContinuationToken);
}
}

Expand All @@ -403,7 +404,7 @@ private OrderByContinuationToken[] ValidateAndExtractContinuationToken(
{
this.TraceWarning($"Invalid JSON in continuation token {requestContinuation} for OrderBy~Context, exception: {ex.Message}");

throw new BadRequestException(RMResources.InvalidContinuationToken, ex);
throw new CosmosException(HttpStatusCode.BadRequest, RMResources.InvalidContinuationToken);
}
}

Expand Down Expand Up @@ -478,7 +479,7 @@ private async Task FilterAsync(
CultureInfo.InvariantCulture,
"Invalid Rid in the continuation token {0} for OrderBy~Context.",
continuationToken.CompositeContinuationToken.Token));
throw new BadRequestException(RMResources.InvalidContinuationToken);
throw new CosmosException(HttpStatusCode.BadRequest, RMResources.InvalidContinuationToken);
}

resourceIds.Add(orderByResult.Rid, rid);
Expand All @@ -492,7 +493,7 @@ private async Task FilterAsync(
CultureInfo.InvariantCulture,
"Invalid Rid in the continuation token {0} for OrderBy~Context.",
continuationToken.CompositeContinuationToken.Token));
throw new BadRequestException(RMResources.InvalidContinuationToken);
throw new CosmosException(HttpStatusCode.BadRequest, RMResources.InvalidContinuationToken);
}

continuationRidVerified = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Microsoft.Azure.Cosmos.Query
using Microsoft.Azure.Cosmos.Internal;
using Microsoft.Azure.Documents;
using Microsoft.Azure.Cosmos.CosmosElements;
using System.Net;

/// <summary>
/// CosmosParallelItemQueryExecutionContext is a concrete implementation for CrossPartitionQueryExecutionContext.
Expand Down Expand Up @@ -200,7 +201,7 @@ private async Task InitializeAsync(
CultureInfo.InvariantCulture,
"Invalid Range in the continuation token {0} for Parallel~Context.",
requestContinuation));
throw new BadRequestException(RMResources.InvalidContinuationToken);
throw new CosmosException(HttpStatusCode.BadRequest, RMResources.InvalidContinuationToken);
}
}

Expand All @@ -210,7 +211,7 @@ private async Task InitializeAsync(
CultureInfo.InvariantCulture,
"Invalid format for continuation token {0} for Parallel~Context.",
requestContinuation));
throw new BadRequestException(RMResources.InvalidContinuationToken);
throw new CosmosException(HttpStatusCode.BadRequest, RMResources.InvalidContinuationToken);
}
}
catch (JsonException ex)
Expand All @@ -221,7 +222,7 @@ private async Task InitializeAsync(
requestContinuation,
ex.Message));

throw new BadRequestException(RMResources.InvalidContinuationToken, ex);
throw new CosmosException(HttpStatusCode.BadRequest, RMResources.InvalidContinuationToken);
}

filteredPartitionKeyRanges = this.GetPartitionKeyRangesForContinuation(suppliedCompositeContinuationTokens, partitionKeyRanges, out targetIndicesForFullContinuation);
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Azure.Cosmos/src/Query/CosmosQueryContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class CosmosQueryContext
public virtual ResourceType ResourceTypeEnum { get; }
public virtual OperationType OperationTypeEnum { get; }
public virtual Type ResourceType { get; }
public virtual SqlQuerySpec SqlQuerySpec { get; }
public SqlQuerySpec SqlQuerySpec { get; internal set; }
public virtual QueryRequestOptions QueryRequestOptions { get; }
public virtual bool IsContinuationExpected { get; }
public virtual bool AllowNonValueAggregateQuery { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private async Task<CosmosContainerSettings> GetContainerSettingsAsync(Cancellati
{
cancellationToken.ThrowIfCancellationRequested();

CosmosContainerSettings containerSettings;
CosmosContainerSettings containerSettings = null;
if (this.cosmosQueryContext.ResourceTypeEnum.IsCollectionChild())
{
CollectionCache collectionCache = await this.cosmosQueryContext.QueryClient.GetCollectionCacheAsync();
Expand All @@ -145,11 +145,6 @@ private async Task<CosmosContainerSettings> GetContainerSettingsAsync(Cancellati
{
containerSettings = await collectionCache.ResolveCollectionAsync(request, cancellationToken);
}

}
else
{
containerSettings = null;
}

if (containerSettings == null)
Expand Down Expand Up @@ -263,6 +258,13 @@ public static async Task<CosmosQueryExecutionContext> CreateSpecializedDocumentQ
string collectionRid,
CancellationToken cancellationToken)
{
if (!string.IsNullOrEmpty(partitionedQueryExecutionInfo.QueryInfo?.RewrittenQuery))
{
cosmosQueryContext.SqlQuerySpec = new SqlQuerySpec(
partitionedQueryExecutionInfo.QueryInfo.RewrittenQuery,
cosmosQueryContext.SqlQuerySpec.Parameters);
}

// Figure out the optimal page size.
long initialPageSize = cosmosQueryContext.QueryRequestOptions.MaxItemCount.GetValueOrDefault(ParallelQueryConfig.GetConfig().ClientInternalPageSize);

Expand Down Expand Up @@ -346,6 +348,7 @@ internal static async Task<List<PartitionKeyRange>> GetTargetPartitionKeyRanges(
List<PartitionKeyRange> targetRanges;
if (queryRequestOptions.PartitionKey != null)
{
// Dis-ambiguate the NonePK if used
PartitionKeyInternal partitionKeyInternal = null;
if (Object.ReferenceEquals(queryRequestOptions.PartitionKey, CosmosContainerSettings.NonePartitionKeyValue))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Microsoft.Azure.Cosmos.Query.ExecutionComponent
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos;
Expand Down Expand Up @@ -49,7 +50,7 @@ public static async Task<TakeDocumentQueryExecutionComponent> CreateLimitDocumen

if (limitContinuationToken.Limit > limitCount)
{
throw new BadRequestException($"limit count in continuation token: {limitContinuationToken.Limit} can not be greater than the limit count in the query: {limitCount}.");
throw new CosmosException(HttpStatusCode.BadRequest, $"limit count in continuation token: {limitContinuationToken.Limit} can not be greater than the limit count in the query: {limitCount}.");
}

return new TakeDocumentQueryExecutionComponent(
Expand All @@ -75,7 +76,7 @@ public static async Task<TakeDocumentQueryExecutionComponent> CreateTopDocumentQ

if (topContinuationToken.Top > topCount)
{
throw new BadRequestException($"top count in continuation token: {topContinuationToken.Top} can not be greater than the top count in the query: {topCount}.");
throw new CosmosException(HttpStatusCode.BadRequest, $"top count in continuation token: {topContinuationToken.Top} can not be greater than the top count in the query: {topCount}.");
}

return new TakeDocumentQueryExecutionComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ private void PopulatePartitionKeyRangeInfo(CosmosRequestMessage request)
if (this.queryContext.ResourceTypeEnum.IsPartitioned())
{
// If the request already has the logical partition key,
// then we shouldn't add the physical partiton key range id.
// then we shouldn't add the physical partition key range id.

bool hasPartitionKey = request.Headers.Get(HttpConstants.HttpHeaders.PartitionKey) != null;
if (!hasPartitionKey)
Expand Down
7 changes: 4 additions & 3 deletions Microsoft.Azure.Cosmos/src/Query/QueryPartitionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@ internal PartitionedQueryExecutionInfoInternal GetPartitionedQueryExecutionInfoI
if (exception != null)
{
DefaultTrace.TraceInformation("QueryEngineConfiguration: " + this.queryengineConfiguration);
throw new BadRequestException(
"Message: " + serializedQueryExecutionInfo,
exception);

throw new CosmosException(
HttpStatusCode.BadRequest,
"Message: " + serializedQueryExecutionInfo);
}

PartitionedQueryExecutionInfoInternal queryInfoInternal =
Expand Down
13 changes: 12 additions & 1 deletion Microsoft.Azure.Cosmos/src/Resource/CosmosException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ public class CosmosException : Exception
{
private readonly CosmosResponseMessageHeaders Headers = null;

internal CosmosException(
HttpStatusCode statusCode,
string message,
Error error = null) :
base(message)
{
this.StatusCode = statusCode;
this.Error = error;
}

internal CosmosException(
CosmosResponseMessage cosmosResponseMessage,
string message,
Expand All @@ -30,7 +40,6 @@ internal CosmosException(
this.ActivityId = this.Headers?.GetHeaderValue<string>(HttpConstants.HttpHeaders.ActivityId);
this.RequestCharge = this.Headers == null ? 0 : this.Headers.GetHeaderValue<double>(HttpConstants.HttpHeaders.RequestCharge);
this.SubStatusCode = (int)this.Headers.SubStatusCode;
this.Error = error;
if (cosmosResponseMessage.Headers.ContentLengthAsLong > 0)
{
using (StreamReader responseReader = new StreamReader(cosmosResponseMessage.Content))
Expand All @@ -39,6 +48,8 @@ internal CosmosException(
}
}
}

this.Error = error;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,12 @@ internal FeedIteratorCore(
/// </summary>
/// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
/// <returns>A query response from cosmos service</returns>
public override Task<CosmosResponseMessage> FetchNextSetAsync(CancellationToken cancellationToken = default(CancellationToken))
public override async Task<CosmosResponseMessage> FetchNextSetAsync(CancellationToken cancellationToken = default(CancellationToken))
{
return this.nextResultSetDelegate(this.MaxItemCount, this.continuationToken, this.queryOptions, this.state, cancellationToken)
.ContinueWith(task =>
{
CosmosResponseMessage response = task.Result;
this.continuationToken = response.Headers.Continuation;
this.HasMoreResults = GetHasMoreResults(this.continuationToken, response.StatusCode);
return response;
}, cancellationToken);
CosmosResponseMessage response = await this.nextResultSetDelegate(this.MaxItemCount, this.continuationToken, this.queryOptions, this.state, cancellationToken);
this.continuationToken = response.Headers.Continuation;
this.HasMoreResults = GetHasMoreResults(this.continuationToken, response.StatusCode);
return response;
}

internal static string GetContinuationToken(CosmosResponseMessage httpResponseMessage)
Expand Down Expand Up @@ -149,19 +145,15 @@ internal FeedIteratorCore(
/// </summary>
/// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
/// <returns>A query response from cosmos service</returns>
public override Task<FeedResponse<T>> FetchNextSetAsync(CancellationToken cancellationToken = default(CancellationToken))
public override async Task<FeedResponse<T>> FetchNextSetAsync(CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();

return this.nextResultSetDelegate(this.MaxItemCount, this.continuationToken, this.queryOptions, this.state, cancellationToken)
.ContinueWith(task =>
{
FeedResponse<T> response = task.Result;
this.HasMoreResults = response.HasMoreResults;
this.continuationToken = response.InternalContinuationToken;

return response;
}, cancellationToken);
FeedResponse<T> response = await this.nextResultSetDelegate(this.MaxItemCount, this.continuationToken, this.queryOptions, this.state, cancellationToken);
this.HasMoreResults = response.HasMoreResults;
this.continuationToken = response.InternalContinuationToken;
return response;

}

internal static ReadFeedResponse<T> CreateCosmosQueryResponse(
Expand Down
Loading