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 bug in OrderByCrossPartitionQueryPipelineStage to ensure that errors in inner pipeline creation are bubbled up #4419

Merged
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 @@ -160,7 +160,7 @@ public async ValueTask<bool> MoveNextAsync(ITrace trace, CancellationToken cance
}

TryCatch<bool> hasNext = await this.inner.TryAsync(pipelineStage => pipelineStage.MoveNextAsync(trace, cancellationToken));
return hasNext.Succeeded && hasNext.Result;
neildsh marked this conversation as resolved.
Show resolved Hide resolved
return hasNext.Failed || hasNext.Result;
}

public ValueTask DisposeAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,58 @@ public async Task TestMixedTypeOrderByAsync()
},
"/id",
indexV2Policy);
}

[TestMethod]
public async Task TestBadOrderByQueriesAsync()
{
const string NoCompositeIndex = "The order by query does not have a corresponding composite index that it can be served from.";
const string OrderByOverCorrelatedPath = "Order-by over correlated collections is not supported.";

static async Task ImplementationAsync(
Container container,
IReadOnlyList<CosmosObject> documents)
{
IReadOnlyList<(string query, string error)> queries = new List<(string query, string error)>
{
("SELECT * FROM c ORDER BY c.id, c.name", NoCompositeIndex),
("SELECT * FROM c ORDER BY c.id DESC, c._ts DESC", NoCompositeIndex),
(
@"SELECT DISTINCT VALUE v2
FROM root
JOIN (
SELECT DISTINCT VALUE v0
FROM root
JOIN v0 IN root.Parents) AS v2
WHERE (LENGTH(v2.FamilyName) > 10)
ORDER BY v2 ASC",
OrderByOverCorrelatedPath
),
};

foreach (bool enableOptmisticDirectExecution in new []{ false, true })
{
QueryRequestOptions options = new QueryRequestOptions()
{
EnableOptimisticDirectExecution = enableOptmisticDirectExecution,
};

foreach ((string query, string error) in queries)
{
using FeedIterator feedIterator = container.GetItemQueryStreamIterator(query, continuationToken: null, options);
neildsh marked this conversation as resolved.
Show resolved Hide resolved
ResponseMessage response = await feedIterator.ReadNextAsync();
Assert.AreEqual(System.Net.HttpStatusCode.BadRequest, response.StatusCode);
Assert.IsNotNull(response.CosmosException);
Assert.IsTrue(response.CosmosException.Message.Contains(error));
}
}
}

await this.CreateIngestQueryDeleteAsync(
ConnectionModes.Direct | ConnectionModes.Gateway,
CollectionTypes.SinglePartition | CollectionTypes.MultiPartition,
new List<string>(),
ImplementationAsync);
}

private sealed class MixedTypedDocument
Expand Down
Loading