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 @@ -205,7 +205,8 @@ private static async Task<TryCatch<IQueryPipelineStage>> TryCreateCoreContextAsy
bool hasDistinct = sqlQuery.SelectClause.HasDistinct;
bool hasGroupBy = sqlQuery.GroupByClause != default;
bool hasAggregates = AggregateProjectionDetector.HasAggregate(sqlQuery.SelectClause.SelectSpec);
bool createPassthroughQuery = !hasAggregates && !hasDistinct && !hasGroupBy;
bool hasOrderBy = sqlQuery.OrderByClause != default;
bool createPassthroughQuery = !hasAggregates && !hasDistinct && !hasGroupBy && !hasOrderBy;

if (createPassthroughQuery)
{
Expand Down Expand Up @@ -305,6 +306,7 @@ private static async Task<TryCatch<IQueryPipelineStage>> TryCreateFromPartitione
&& partitionedQueryExecutionInfo.QueryRanges[0].IsSingleValue);
bool serverStreamingQuery = !partitionedQueryExecutionInfo.QueryInfo.HasAggregates
&& !partitionedQueryExecutionInfo.QueryInfo.HasDistinct
&& !partitionedQueryExecutionInfo.QueryInfo.HasNonStreamingOrderBy
&& !partitionedQueryExecutionInfo.QueryInfo.HasGroupBy;
bool streamingSinglePartitionQuery = singleLogicalPartitionKeyQuery && serverStreamingQuery;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public static TryCatch<IQueryPipelineStage> MonadicCreate(
{
TryCatch<IQueryPipelineStage> ComponentPipelineFactory(QueryInfo rewrittenQueryInfo)
{
HybridSearchDebugTraceHelpers.TraceQuerySpec(sqlQuerySpec);

return PipelineFactory.MonadicCreate(
documentContainer,
sqlQuerySpec,
Expand Down Expand Up @@ -289,6 +291,8 @@ private async ValueTask<bool> MoveNextAsync_DrainSingletonComponentAsync(ITrace

QueryPage page = sourceStage.Current.Result;

HybridSearchDebugTraceHelpers.TraceQueryResultTSVHeader(1);

List<CosmosElement> documents = new List<CosmosElement>(page.Documents.Count);
foreach (CosmosElement cosmosElement in page.Documents)
{
Expand Down Expand Up @@ -950,6 +954,19 @@ private static class HybridSearchDebugTraceHelpers
private const bool Enabled = false;
#pragma warning disable CS0162 // Unreachable code detected

[Conditional("DEBUG")]
public static void TraceQuerySpec(SqlQuerySpec querySpec)
{
if (Enabled)
{
CosmosSerializerCore serializerCore = new CosmosSerializerCore();
System.IO.Stream stream = serializerCore.ToStreamSqlQuerySpec(querySpec, ResourceType.Document);
string content = new System.IO.StreamReader(stream).ReadToEnd();
System.Diagnostics.Trace.WriteLine(content);
System.Diagnostics.Trace.WriteLine("\n");
}
}

[Conditional("DEBUG")]
public static void TraceQueryResults(IReadOnlyList<HybridSearchQueryResult> queryResults, int componentCount)
{
Expand Down Expand Up @@ -1026,7 +1043,7 @@ private static StringBuilder AppendQueryResult(HybridSearchQueryResult queryResu
return builder;
}

private static void TraceQueryResultTSVHeader(int componentCount)
public static void TraceQueryResultTSVHeader(int componentCount)
{
StringBuilder builder = new StringBuilder();
builder.Append("_rid");
Expand Down
Loading
Loading