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

[Internal] Query : Removes PartitionKey from Enumerator #4350

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -253,7 +253,6 @@ public async ValueTask<bool> MoveNextAsync(ITrace trace)
queryDataSource,
sqlQuerySpec,
feedRangeState,
partitionKey,
queryPaginationOptions,
cancellationToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ internal sealed class QueryPartitionRangePageAsyncEnumerator : PartitionRangePag
private readonly IQueryDataSource queryDataSource;
private readonly SqlQuerySpec sqlQuerySpec;
private readonly QueryPaginationOptions queryPaginationOptions;
private readonly Cosmos.PartitionKey? partitionKey;

public QueryPartitionRangePageAsyncEnumerator(
IQueryDataSource queryDataSource,
SqlQuerySpec sqlQuerySpec,
FeedRangeState<QueryState> feedRangeState,
Cosmos.PartitionKey? partitionKey,
QueryPaginationOptions queryPaginationOptions,
CancellationToken cancellationToken)
: base(feedRangeState, cancellationToken)
{
this.queryDataSource = queryDataSource ?? throw new ArgumentNullException(nameof(queryDataSource));
this.sqlQuerySpec = sqlQuerySpec ?? throw new ArgumentNullException(nameof(sqlQuerySpec));
this.queryPaginationOptions = queryPaginationOptions;
this.partitionKey = partitionKey;
}

public override ValueTask DisposeAsync() => default;
Expand All @@ -43,12 +40,9 @@ protected override Task<TryCatch<QueryPage>> GetNextPageAsync(ITrace trace, Canc
throw new ArgumentNullException(nameof(trace));
}

// We sadly need to check the partition key, since a user can set a partition key in the request options with a different continuation token.
// In the future the partition filtering and continuation information needs to be a tightly bounded contract (like cross feed range state).
FeedRangeInternal feedRange = this.partitionKey.HasValue ? new FeedRangePartitionKey(this.partitionKey.Value) : this.FeedRangeState.FeedRange;
return this.queryDataSource.MonadicQueryAsync(
sqlQuerySpec: this.sqlQuerySpec,
feedRangeState: new FeedRangeState<QueryState>(feedRange, this.FeedRangeState.State),
feedRangeState: this.FeedRangeState,
queryPaginationOptions: this.queryPaginationOptions,
trace: trace,
cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ public async ValueTask<bool> MoveNextAsync(ITrace trace)
documentContainer,
updatedSqlQuerySpec,
feedRangeState,
partitionKey,
queryPaginationOptions,
cancellationToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public async Task TestSplitAsync()
queryDataSource: documentContainer,
sqlQuerySpec: new Cosmos.Query.Core.SqlQuerySpec("SELECT * FROM c"),
feedRangeState: feedRangeState,
partitionKey: null,
queryPaginationOptions: new QueryPaginationOptions(pageSizeHint: 10),
cancellationToken: default),
trace: NoOpTrace.Singleton);
Expand Down Expand Up @@ -142,7 +141,6 @@ public override IReadOnlyList<Record> GetRecordsFromPage(QueryPage page)
queryDataSource: documentContainer,
sqlQuerySpec: new Cosmos.Query.Core.SqlQuerySpec("SELECT * FROM c"),
feedRangeState: feedRangeState,
partitionKey: null,
queryPaginationOptions: new QueryPaginationOptions(pageSizeHint: 10),
cancellationToken: default),
trace: NoOpTrace.Singleton);
Expand All @@ -165,7 +163,6 @@ public override IReadOnlyList<Record> GetRecordsFromPage(QueryPage page)
queryDataSource: documentContainer,
sqlQuerySpec: new Cosmos.Query.Core.SqlQuerySpec("SELECT * FROM c"),
feedRangeState: new FeedRangeState<QueryState>(ranges[0], state),
partitionKey: null,
queryPaginationOptions: new QueryPaginationOptions(pageSizeHint: 10),
cancellationToken: cancellationToken),
trace: NoOpTrace.Singleton);
Expand Down