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: Fixes order by logic to throw original exception instead of AggregateException #2708

Merged
Changes from 2 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 @@ -22,7 +22,7 @@ public OrderByQueryPartitionRangePageAsyncEnumerator(
SqlQuerySpec sqlQuerySpec,
FeedRangeState<QueryState> feedRangeState,
PartitionKey? partitionKey,
QueryPaginationOptions queryPagingationOptions,
QueryPaginationOptions queryPaginationOptions,
string filter,
CancellationToken cancellationToken)
: base(feedRangeState, cancellationToken)
Expand All @@ -33,7 +33,7 @@ public OrderByQueryPartitionRangePageAsyncEnumerator(
sqlQuerySpec,
feedRangeState,
partitionKey,
queryPagingationOptions,
queryPaginationOptions,
filter,
cancellationToken);
this.bufferedEnumerator = new BufferedPartitionRangePageAsyncEnumerator<OrderByQueryPage, QueryState>(
Expand Down Expand Up @@ -92,31 +92,25 @@ public InnerEnumerator(

public override ValueTask DisposeAsync() => default;

protected override Task<TryCatch<OrderByQueryPage>> GetNextPageAsync(ITrace trace, CancellationToken cancellationToken)
protected override async Task<TryCatch<OrderByQueryPage>> GetNextPageAsync(ITrace trace, CancellationToken cancellationToken)
{
// Unfortunately we need to keep both the epk range and partition key for queries
// Since the continuation token format uses epk range even though we only need the partition key to route the request.
FeedRangeInternal feedRange = this.PartitionKey.HasValue ? new FeedRangePartitionKey(this.PartitionKey.Value) : this.FeedRangeState.FeedRange;

return this.queryDataSource
TryCatch<QueryPage> monadicQueryPage = await this.queryDataSource
.MonadicQueryAsync(
sqlQuerySpec: this.SqlQuerySpec,
feedRangeState: new FeedRangeState<QueryState>(feedRange, this.FeedRangeState.State),
queryPaginationOptions: this.queryPaginationOptions,
trace: trace,
cancellationToken)
.ContinueWith<TryCatch<OrderByQueryPage>>(antecedent =>
{
TryCatch<QueryPage> monadicQueryPage = antecedent.Result;
if (monadicQueryPage.Failed)
{
Console.WriteLine(this.SqlQuerySpec);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

return TryCatch<OrderByQueryPage>.FromException(monadicQueryPage.Exception);
}

QueryPage queryPage = monadicQueryPage.Result;
return TryCatch<OrderByQueryPage>.FromResult(new OrderByQueryPage(queryPage));
});
cancellationToken);
if (monadicQueryPage.Failed)
j82w marked this conversation as resolved.
Show resolved Hide resolved
{
return TryCatch<OrderByQueryPage>.FromException(monadicQueryPage.Exception);
}
QueryPage queryPage = monadicQueryPage.Result;
return TryCatch<OrderByQueryPage>.FromResult(new OrderByQueryPage(queryPage));
}
}
}
Expand Down