Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
4a83556
Route Execute Stored Procedure requests to Thin Proxy endpoint.
jeet1995 Jan 20, 2026
325ff0a
Route Execute Stored Procedure and QueryPlan requests to Thin Proxy e…
jeet1995 Jan 21, 2026
eb9a83e
Ensure QueryPlan gets routed to Gateway Service Endpoint (in non-TC +…
jeet1995 Jan 23, 2026
1492b36
Ensure QueryPlan gets routed to Gateway Service Endpoint (in non-TC +…
jeet1995 Jan 23, 2026
2c8a5f3
Ensure QueryPlan gets routed to Gateway Service Endpoint (in non-TC +…
jeet1995 Jan 23, 2026
1e14a7b
Obtain List<Range<String>> from List<PartitionKeyInternal>.
jeet1995 Jan 28, 2026
91116c9
Obtain List<Range<String>> from List<PartitionKeyInternal>.
jeet1995 Jan 28, 2026
688a5ac
Adding query + thin-client tests.
jeet1995 Jan 28, 2026
8ae321f
Fixing tests.
jeet1995 Jan 29, 2026
e76c84c
Fixing tests.
jeet1995 Jan 29, 2026
7f3bad8
Fixing tests.
jeet1995 Jan 30, 2026
7600598
Addressing review comments.
jeet1995 Jan 30, 2026
281bc88
Addressing review comments.
jeet1995 Mar 7, 2026
1d171f5
Refactor thin-client E2E tests based on operation type.
jeet1995 Mar 9, 2026
9f1b4ee
Refactor thin-client E2E tests based on operation type.
jeet1995 Mar 9, 2026
cfe720b
Refactor thin-client E2E tests based on operation type.
jeet1995 Mar 9, 2026
8f1615b
Refactor thin-client E2E tests based on operation type.
jeet1995 Mar 9, 2026
b037a1d
Refactor thin-client E2E tests based on operation type.
jeet1995 Mar 10, 2026
8e28d82
Refactor thin-client E2E tests based on operation type.
jeet1995 Mar 10, 2026
2be1433
Refactor thin-client E2E tests based on operation type.
jeet1995 Mar 10, 2026
4b44cd5
Refactor thin-client E2E tests based on operation type.
jeet1995 Mar 10, 2026
afa9811
Merge branch 'Azure:main' into AzCosmos_GatewayV2_QueryPlanSupport
jeet1995 Mar 10, 2026
b07b104
Refactor thin-client E2E tests based on operation type.
jeet1995 Mar 10, 2026
22db578
Merge remote-tracking branch 'azure/main' into AzCosmos_GatewayV2_Que…
jeet1995 Mar 30, 2026
a991123
Add SupportedQueryFeatures and QueryVersion RNTBD request headers for…
jeet1995 Mar 30, 2026
7ab7ffa
Add change feed tests for FeedRange.forFullRange and forLogicalPartition
jeet1995 Mar 30, 2026
f9b2874
Add thin client E2E test matrix documentation for QueryPlan review
jeet1995 Mar 30, 2026
06b1a8c
Add SupportedQueryFeatures and QueryVersion RNTBD request headers for…
jeet1995 Mar 30, 2026
d006c72
Fix testGetCurrentDateTime flaky assertion, add AAD auth support, RNT…
jeet1995 Mar 31, 2026
01b54ec
Refactor thin client query tests for reliability
jeet1995 Mar 31, 2026
37c0d9d
Fix container leaks and Direct TCP AAD auth in tests
jeet1995 Mar 31, 2026
d65e174
Use bulkDelete in AfterClass for seeded docs cleanup
jeet1995 Mar 31, 2026
c7c31c4
Address PR review feedback
jeet1995 Mar 31, 2026
9372597
Align vector/FTS/hybrid tests with existing patterns
jeet1995 Mar 31, 2026
8fb7e24
Address review agent comments + fix broken link
jeet1995 Mar 31, 2026
01feecf
Address review agent comments (round 2)
jeet1995 Mar 31, 2026
a3cded4
Refactor queryRanges deserialization — detect format from response, n…
jeet1995 Apr 1, 2026
2422cbc
Use agnostic QueryRangesFormat hint instead of PartitionKeyDefinition…
jeet1995 Apr 1, 2026
10549fc
Merge remote-tracking branch 'azure/main' into AzCosmos_GatewayV2_Que…
jeet1995 Apr 1, 2026
2d7db15
Merge remote-tracking branch 'upstream/main' into AzCosmos_GatewayV2_…
jeet1995 Jun 2, 2026
86683a8
Fix fetchQueryPlanForValidation caller after merge
jeet1995 Jun 2, 2026
e27bf3f
Make PartitionedQueryExecutionInfo(ObjectNode, RequestTimeline) ctor …
jeet1995 Jun 2, 2026
60c1dab
[Cosmos] Default thin-client to enabled and add HTTP/2 connectivity-p…
jeet1995 Jun 10, 2026
91bf62a
Merge upstream/main into jeet1995/thin-client-probe-flow
jeet1995 Jun 10, 2026
d2ec2f8
Address PR #49437 review comments: probe single-flight, body-drain li…
jeet1995 Jun 10, 2026
3f1b1be
Address PR #49437 second-batch review feedback
jeet1995 Jun 10, 2026
66fca70
Clarify CHANGELOG: probe recovery threshold is now configurable
jeet1995 Jun 10, 2026
8a602fb
Address PR #49437 review (rounds 4-8): reactor-chain probe, FQN clean…
jeet1995 Jun 10, 2026
4a31ea0
Fix CI test fallout from default ThinClient enablement
jeet1995 Jun 11, 2026
ccc7c39
Disable thin-client probe in Http2PingKeepaliveTest
jeet1995 Jun 11, 2026
ad9e3df
Disable thin-client probe by default for E2E tests in TestSuiteBase
jeet1995 Jun 11, 2026
e381f3a
Revert "Disable thin-client probe by default for E2E tests in TestSui…
jeet1995 Jun 11, 2026
da6c698
Add per-class thinclient probe disable in CosmosNotFoundTests and Per…
jeet1995 Jun 11, 2026
5473c00
Merge remote-tracking branch 'origin/jeet1995/thin-client-probe-flow'…
jeet1995 Jun 12, 2026
edfff97
Add unit tests for QueryPlan and stored-procedure thin-client routing
jeet1995 Jun 12, 2026
9d74638
Remove endpoint-probe content from QueryPlan PR branch
jeet1995 Jun 12, 2026
df1ed37
Merge upstream/main into AzCosmos_GatewayV2_QueryPlanSupport
jeet1995 Jun 12, 2026
f881c0d
Propagate hybrid query diagnostics
jeet1995 Jun 12, 2026
156aaa3
Advertise CountIf query feature
jeet1995 Jun 12, 2026
610003e
Address query plan review feedback
jeet1995 Jun 13, 2026
ffe50dc
Share thin client test property setup
jeet1995 Jun 13, 2026
1f1c7d3
Clean up query range conversion state
jeet1995 Jun 13, 2026
e95e65d
Thread DocumentCollection into readMany query-plan validation
jeet1995 Jun 14, 2026
7148ca3
Cover ReadManyByPartitionKey QueryPlan bifurcation with unit + E2E tests
jeet1995 Jun 14, 2026
c267df6
Skip RNTBD QueryPlan frames when capturing V2 feed requests
Jun 15, 2026
a4185e5
Fix thin-client QueryPlan error returning statusCode 0 instead of 400
jeet1995 Jun 16, 2026
65b23d9
Harden ThinClientQueryE2ETest assertions (F1-F5)
jeet1995 Jun 16, 2026
5b11c3b
Replace thin-client test matrix with reverse-engineered E2E test spec
jeet1995 Jun 16, 2026
5541846
Apply Aditya Sarpotdar review feedback to thin-client E2E tests
jeet1995 Jun 17, 2026
7eb5822
Merge remote-tracking branch 'upstream/main' into AzCosmos_GatewayV2_…
jeet1995 Jun 24, 2026
f554ef2
Address review feedback: opt-in thin-client QueryPlan routing + kill-…
jeet1995 Jun 24, 2026
273b31c
Address review feedback: broaden gateway error fallback to ClassCastE…
jeet1995 Jun 24, 2026
4aefb59
Make thin-client QueryPlan no-EPK-headers contract explicit in wrapIn…
jeet1995 Jun 24, 2026
a4b844d
Fix missing StandardCharsets import in RxGatewayStoreModelTest
jeet1995 Jun 24, 2026
87ab2c0
Test: add QueryOracle-derived LIKE/scalar-expression thin-client pari…
jeet1995 Jun 25, 2026
d16ab54
Test: verify a cached proxy-generated query plan still executes corre…
jeet1995 Jun 25, 2026
19204b3
Test: cross-partition tests use a dedicated multi-physical-partition …
jeet1995 Jun 25, 2026
48b0a45
Add CHANGELOG entry for QueryPlan request routing to Gateway V2
jeet1995 Jun 25, 2026
5bb942c
Call out Execute Stored Procedure support in CHANGELOG entry
jeet1995 Jun 25, 2026
a70c9f8
Fix flaky region/timing-sensitive fault-injection E2E tests
jeet1995 Jun 26, 2026
f12b34c
Remove test AAD auth toggle; move thin-client test matrix to docs/ an…
jeet1995 Jun 26, 2026
427ae9d
Merge commit 'ccb0163cad4' into AzCosmos_GatewayV2_QueryPlanSupport
jeet1995 Jun 26, 2026
94dc07f
Add cross-partition aggregate / GROUP BY parity tests for thin-client…
jeet1995 Jun 30, 2026
26e4235
Fix thin-client MULTI_HASH prefix EPK over-span; add QueryPlan parity…
jeet1995 Jun 30, 2026
dc02999
Merge upstream/main into AzCosmos_GatewayV2_QueryPlanSupport
jeet1995 Jul 8, 2026
694dc71
Enforce QueryPlan thin-client routing invariant and harden container-…
jeet1995 Jul 8, 2026
bf30911
Add kill-switch flip validation for QueryPlan thin-client routing
jeet1995 Jul 8, 2026
e578d4b
Merge remote-tracking branch 'upstream/main' into AzCosmos_GatewayV2_…
jeet1995 Jul 8, 2026
3637b39
Restore ambient COSMOS.THINCLIENT_ENABLED in ThinClientTestBase teardown
jeet1995 Jul 9, 2026
565c608
Remove redundant COSMOS.THINCLIENT_ENABLED mutation from ThinClientTe…
jeet1995 Jul 9, 2026
cbbdce7
Merge branch 'main' into AzCosmos_GatewayV2_QueryPlanSupport
jeet1995 Jul 9, 2026
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,27 @@ public <T> Map<String, T> getMap(String propertyKey) {
return null;
}

/**
* Gets a map value with empty string values converted to null.
* This is useful for handling JSON responses where empty strings are used instead of null.
*
* @param <T> the type of the map values.
* @param propertyKey the property to get.
* @return the map with empty string values converted to null.
*/
@SuppressWarnings("unchecked")
public <T> Map<String, T> getMapWithEmptyStringAsNull(String propertyKey) {
Comment thread
jeet1995 marked this conversation as resolved.
Outdated
if (this.propertyBag.has(propertyKey)) {
Object value = this.get(propertyKey);
Map<String, T> map = (Map<String, T>) OBJECT_MAPPER.convertValue(value, HashMap.class);
if (map != null) {
map.replaceAll((k, v) -> (v instanceof String && ((String) v).isEmpty()) ? null : v);
}
return map;
}
return null;
}

/**
* Checks whether a property exists.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4682,6 +4682,11 @@ public GlobalEndpointManager getGlobalEndpointManager() {
public GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker getGlobalPartitionEndpointManagerForCircuitBreaker() {
return RxDocumentClientImpl.this.globalPartitionEndpointManagerForPerPartitionCircuitBreaker;
}

@Override
public boolean useThinClient(RxDocumentServiceRequest request) {
return RxDocumentClientImpl.this.useThinClientStoreModel(request);
}
};
}

Expand Down Expand Up @@ -6451,7 +6456,8 @@ private RxStoreModel getStoreProxy(RxDocumentServiceRequest request) {
resourceType == ResourceType.ClientEncryptionKey ||
resourceType.isScript() && operationType != OperationType.ExecuteJavaScript ||
resourceType == ResourceType.PartitionKeyRange ||
resourceType == ResourceType.PartitionKey && operationType == OperationType.Delete) {
resourceType == ResourceType.PartitionKey && operationType == OperationType.Delete ||
operationType == OperationType.QueryPlan) {
Comment thread
jeet1995 marked this conversation as resolved.
return this.gatewayProxy;
}

Expand Down Expand Up @@ -6489,7 +6495,7 @@ private RxStoreModel getStoreProxy(RxDocumentServiceRequest request) {
if ((operationType == OperationType.Query ||
operationType == OperationType.SqlQuery ||
operationType == OperationType.ReadFeed) &&
Utils.isCollectionChild(request.getResourceType())) {
Utils.isCollectionChild(request.getResourceType())) {
// Go to gateway only when partition key range and partition key are not set. This should be very rare
if (request.getPartitionKeyRangeIdentity() == null &&
request.getHeaders().get(HttpConstants.HttpHeaders.PARTITION_KEY) == null) {
Expand Down Expand Up @@ -8009,7 +8015,7 @@ public boolean useThinClient() {
private boolean useThinClientStoreModel(RxDocumentServiceRequest request) {
if (!useThinClient
|| !this.globalEndpointManager.hasThinClientReadLocations()
|| request.getResourceType() != ResourceType.Document) {
|| request.getResourceType() != ResourceType.Document && !request.isExecuteStoredProcedureBasedRequest()) {
Comment thread
jeet1995 marked this conversation as resolved.
Outdated

return false;
}
Expand All @@ -8019,7 +8025,9 @@ private boolean useThinClientStoreModel(RxDocumentServiceRequest request) {
return operationType.isPointOperation()
|| operationType == OperationType.Query
|| operationType == OperationType.Batch
|| request.isChangeFeedRequest() && !request.isAllVersionsAndDeletesChangeFeedMode();
|| request.isChangeFeedRequest() && !request.isAllVersionsAndDeletesChangeFeedMode()
|| request.isExecuteStoredProcedureBasedRequest()
|| operationType == OperationType.QueryPlan;
Comment thread
jeet1995 marked this conversation as resolved.
}

private DocumentClientRetryPolicy getRetryPolicyForPointOperation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,10 @@ public boolean isChangeFeedRequest() {
return this.headers.containsKey(HttpConstants.HttpHeaders.A_IM);
}

public boolean isExecuteStoredProcedureBasedRequest() {
return this.resourceType == ResourceType.StoredProcedure && this.operationType == OperationType.ExecuteJavaScript;
}

public boolean isAllVersionsAndDeletesChangeFeedMode() {
String aImHeader = this.headers.get(HttpConstants.HttpHeaders.A_IM);
return this.headers.containsKey(HttpConstants.HttpHeaders.A_IM) && HttpConstants.A_IMHeaderValues.FULL_FIDELITY_FEED.equals(aImHeader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,13 @@ public HttpRequest wrapInHttpRequest(RxDocumentServiceRequest request, URI reque
byte[] epk = partitionKey.getEffectivePartitionKeyBytes(request.getPartitionKeyInternal(), request.getPartitionKeyDefinition());
rntbdRequest.setHeaderValue(RntbdConstants.RntbdRequestHeader.EffectivePartitionKey, epk);
} else if (request.requestContext.resolvedPartitionKeyRange == null) {
throw new IllegalStateException(
"Resolved partition key range should not be null at this point. ResourceType: "
+ request.getResourceType() + ", OperationType: "
+ request.getOperationType());

if (!(request.getOperationType() == OperationType.QueryPlan)) {
Comment thread
jeet1995 marked this conversation as resolved.
Outdated
throw new IllegalStateException(
"Resolved partition key range should not be null at this point. ResourceType: "
+ request.getResourceType() + ", OperationType: "
+ request.getOperationType());
}
} else {
PartitionKeyRange pkRange = request.requestContext.resolvedPartitionKeyRange;
rntbdRequest.setHeaderValue(RntbdConstants.RntbdRequestHeader.StartEpkHash, HexConvert.hexToBytes(pkRange.getMinInclusive()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ public enum RntbdOperationType {
PreReplaceValidation((short) 0x0020, OperationType.PreReplaceValidation),
AddComputeGatewayRequestCharges((short) 0x0021, OperationType.AddComputeGatewayRequestCharges),
MigratePartition((short) 0x0022, OperationType.MigratePartition),
Batch((short) 0x0025, OperationType.Batch);
Batch((short) 0x0025, OperationType.Batch),
QueryPlan((short) 0x0042, OperationType.QueryPlan);
Comment thread
jeet1995 marked this conversation as resolved.

private final short id;
private final OperationType type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ private static RntbdOperationType map(final OperationType operationType) {
return RntbdOperationType.AddComputeGatewayRequestCharges;
case Batch:
return RntbdOperationType.Batch;
case QueryPlan:
return RntbdOperationType.QueryPlan;
default:
final String reason = String.format("Unrecognized operation type: %s", operationType);
throw new UnsupportedOperationException(reason);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ private static <T> Mono<PartitionKeyRangesAndQueryInfos> getPartitionKeyRangesAn
client,
query,
resourceLink,
cosmosQueryRequestOptions);
cosmosQueryRequestOptions,
collection);

return queryExecutionInfoMono.flatMap(
partitionedQueryExecutionInfo -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ Mono<RxDocumentServiceRequest> addPartitionLevelUnavailableRegionsOnRequest(
GlobalEndpointManager getGlobalEndpointManager();

GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker getGlobalPartitionEndpointManagerForCircuitBreaker();

boolean useThinClient(RxDocumentServiceRequest request);
Comment thread
jeet1995 marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
package com.azure.cosmos.implementation.query;

import com.azure.cosmos.implementation.RequestTimeline;
import com.azure.cosmos.implementation.Utils;
import com.azure.cosmos.implementation.query.hybridsearch.HybridSearchQueryInfo;
import com.azure.cosmos.implementation.routing.PartitionKeyInternal;
import com.azure.cosmos.implementation.routing.PartitionKeyInternalHelper;
import com.azure.cosmos.implementation.routing.Range;
import com.azure.cosmos.implementation.JsonSerializable;
import com.azure.cosmos.implementation.Constants;
import com.azure.cosmos.models.PartitionKeyDefinition;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -24,10 +31,14 @@ public final class PartitionedQueryExecutionInfo extends JsonSerializable {
private List<Range<String>> queryRanges;
private RequestTimeline queryPlanRequestTimeline;
private HybridSearchQueryInfo hybridSearchQueryInfo;
private final boolean useThinClientMode;
private final PartitionKeyDefinition partitionKeyDefinition;

PartitionedQueryExecutionInfo(QueryInfo queryInfo, List<Range<String>> queryRanges) {
this.queryInfo = queryInfo;
this.queryRanges = queryRanges;
this.useThinClientMode = false;
this.partitionKeyDefinition = null;

this.set(
PartitionedQueryExecutionInfoInternal.PARTITIONED_QUERY_EXECUTION_INFO_VERSION_PROPERTY,
Expand All @@ -38,10 +49,21 @@ public final class PartitionedQueryExecutionInfo extends JsonSerializable {
public PartitionedQueryExecutionInfo(ObjectNode content, RequestTimeline queryPlanRequestTimeline) {
super(content);
this.queryPlanRequestTimeline = queryPlanRequestTimeline;
this.useThinClientMode = false;
this.partitionKeyDefinition = null;
}

public PartitionedQueryExecutionInfo(ObjectNode content, RequestTimeline queryPlanRequestTimeline, boolean useThinClientMode, PartitionKeyDefinition partitionKeyDefinition) {
super(content);
this.queryPlanRequestTimeline = queryPlanRequestTimeline;
this.useThinClientMode = useThinClientMode;
this.partitionKeyDefinition = partitionKeyDefinition;
}
Comment thread
jeet1995 marked this conversation as resolved.

public PartitionedQueryExecutionInfo(String jsonString) {
super(jsonString);
this.useThinClientMode = false;
this.partitionKeyDefinition = null;
}

public int getVersion() {
Expand All @@ -55,9 +77,90 @@ public QueryInfo getQueryInfo() {
}

public List<Range<String>> getQueryRanges() {
return this.queryRanges != null ? this.queryRanges
: (this.queryRanges = super.getList(
PartitionedQueryExecutionInfoInternal.QUERY_RANGES_PROPERTY, QUERY_RANGES_CLASS));
if (this.queryRanges != null) {
return this.queryRanges;
}

if (this.useThinClientMode) {
// In thin client mode, the proxy returns queryRanges in PartitionKeyInternal array format
// (e.g., {"min": [[""]], "max": [["Infinity"]]}) which needs to be converted to EPK hex strings.
// We need to manually parse this since the generic Range<T> deserialization doesn't handle
// PartitionKeyInternal properly (it keeps the raw ArrayNode).
this.queryRanges = parseQueryRangesForThinClient();
} else {
// In non-thin client mode, the Gateway returns queryRanges directly as EPK hex strings
this.queryRanges = super.getList(
PartitionedQueryExecutionInfoInternal.QUERY_RANGES_PROPERTY, QUERY_RANGES_CLASS);
}

return this.queryRanges;
}

/**
* Parses the queryRanges JSON array for thin client mode.
* The thin client proxy returns ranges in the format:
* [{"min": [[""]], "max": [["Infinity"]], "isMinInclusive": true, "isMaxInclusive": false}]
* where min/max are PartitionKeyInternal JSON representations that need to be converted to EPK strings.
*
* @return List of ranges with EPK hex string min/max values
*/
private List<Range<String>> parseQueryRangesForThinClient() {
ObjectNode propertyBag = this.getPropertyBag();
JsonNode queryRangesNode = propertyBag.get(PartitionedQueryExecutionInfoInternal.QUERY_RANGES_PROPERTY);

if (queryRangesNode == null || !queryRangesNode.isArray()) {
return null;
}

ArrayNode rangesArray = (ArrayNode) queryRangesNode;
List<Range<String>> epkRanges = new ArrayList<>(rangesArray.size());

for (JsonNode rangeNode : rangesArray) {
if (!rangeNode.isObject()) {
continue;
}

ObjectNode rangeObject = (ObjectNode) rangeNode;

// Parse min and max as PartitionKeyInternal
JsonNode minNode = rangeObject.get("min");
JsonNode maxNode = rangeObject.get("max");

PartitionKeyInternal minPk = parsePartitionKeyInternal(minNode);
PartitionKeyInternal maxPk = parsePartitionKeyInternal(maxNode);

// Convert to EPK strings
String minEpk = PartitionKeyInternalHelper.getEffectivePartitionKeyString(minPk, this.partitionKeyDefinition);
String maxEpk = PartitionKeyInternalHelper.getEffectivePartitionKeyString(maxPk, this.partitionKeyDefinition);

// Parse isMinInclusive and isMaxInclusive (defaults: min=true, max=false)
boolean isMinInclusive = !rangeObject.has("isMinInclusive") || rangeObject.get("isMinInclusive").asBoolean(true);
boolean isMaxInclusive = rangeObject.has("isMaxInclusive") && rangeObject.get("isMaxInclusive").asBoolean(false);

epkRanges.add(new Range<>(minEpk, maxEpk, isMinInclusive, isMaxInclusive));
}

return epkRanges;
}

/**
* Parses a JSON node representing a PartitionKeyInternal.
* Handles formats like [[""]] (empty), [["Infinity"]] (infinity), or actual partition key values.
*
* @param node The JSON node to parse
* @return The parsed PartitionKeyInternal
*/
private PartitionKeyInternal parsePartitionKeyInternal(JsonNode node) {
if (node == null || node.isNull()) {
return PartitionKeyInternal.EmptyPartitionKey;
}

try {
// Use Jackson to deserialize using PartitionKeyInternal's custom deserializer
return Utils.getSimpleObjectMapper().treeToValue(node, PartitionKeyInternal.class);
} catch (Exception e) {
Comment thread
jeet1995 marked this conversation as resolved.
Outdated
throw new IllegalStateException("Failed to parse PartitionKeyInternal from JSON: " + node, e);
}
}

public RequestTimeline getQueryPlanRequestTimeline() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ public boolean hasNonStreamingOrderBy() {

public Map<String, AggregateOperator> getGroupByAliasToAggregateType(){
Map<String, AggregateOperator> groupByAliasToAggregateMap;
groupByAliasToAggregateMap = super.getMap("groupByAliasToAggregateType");
// Use getMapWithEmptyStringAsNull to handle thin client responses where
// empty strings are returned instead of null values
groupByAliasToAggregateMap = super.getMapWithEmptyStringAsNull("groupByAliasToAggregateType");
return groupByAliasToAggregateMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import com.azure.cosmos.CosmosException;
import com.azure.cosmos.implementation.Configs;
import com.azure.cosmos.implementation.DiagnosticsClientContext;
import com.azure.cosmos.implementation.DocumentCollection;
import com.azure.cosmos.implementation.ImplementationBridgeHelpers;
import com.azure.cosmos.implementation.PathsHelper;
import com.azure.cosmos.implementation.Utils;
import com.azure.cosmos.implementation.routing.PartitionKeyInternal;
import com.azure.cosmos.models.CosmosQueryRequestOptions;
import com.azure.cosmos.models.ModelBridgeInternal;
import com.azure.cosmos.models.PartitionKey;
import com.azure.cosmos.models.PartitionKeyDefinition;
import com.azure.cosmos.models.SqlQuerySpec;
import com.azure.cosmos.implementation.BackoffRetryUtility;
import com.azure.cosmos.implementation.DocumentClientRetryPolicy;
Expand Down Expand Up @@ -78,14 +80,17 @@ static Mono<PartitionedQueryExecutionInfo> getQueryPlanThroughGatewayAsync(Diagn
IDocumentQueryClient queryClient,
SqlQuerySpec sqlQuerySpec,
String resourceLink,
CosmosQueryRequestOptions initialQueryRequestOptions) {
CosmosQueryRequestOptions initialQueryRequestOptions,
DocumentCollection collection) {

CosmosQueryRequestOptions nonNullRequestOptions = initialQueryRequestOptions != null
? initialQueryRequestOptions
: new CosmosQueryRequestOptions();

PartitionKey partitionKey = nonNullRequestOptions.getPartitionKey();

PartitionKeyDefinition partitionKeyDefinition = collection != null ? collection.getPartitionKey() : null;
Comment thread
jeet1995 marked this conversation as resolved.


final Map<String, String> requestHeaders = new HashMap<>();
requestHeaders.put(HttpConstants.HttpHeaders.CONTENT_TYPE, RuntimeConstants.MediaTypes.JSON);
Expand All @@ -104,7 +109,9 @@ static Mono<PartitionedQueryExecutionInfo> getQueryPlanThroughGatewayAsync(Diagn
ResourceType.Document,
resourceLink,
requestHeaders);
queryPlanRequest.useGatewayMode = true;

// queryPlanRequest.useGatewayMode = true;
Comment thread
jeet1995 marked this conversation as resolved.
Outdated

queryPlanRequest.setByteBuffer(ModelBridgeInternal.serializeJsonToByteBuffer(sqlQuerySpec));

CosmosEndToEndOperationLatencyPolicyConfig end2EndConfig = qryOptAccessor
Expand Down Expand Up @@ -133,7 +140,9 @@ static Mono<PartitionedQueryExecutionInfo> getQueryPlanThroughGatewayAsync(Diagn
PartitionedQueryExecutionInfo partitionedQueryExecutionInfo =
new PartitionedQueryExecutionInfo(
(ObjectNode) rxDocumentServiceResponse.getResponseBody(),
rxDocumentServiceResponse.getGatewayHttpRequestTimeline());
rxDocumentServiceResponse.getGatewayHttpRequestTimeline(),
queryClient.useThinClient(queryPlanRequest),
partitionKeyDefinition);
return Mono.just(partitionedQueryExecutionInfo);
});
}, retryPolicyInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public static SingleGroupAggregator create(
for (Map.Entry<String, AggregateOperator> aliasToAggregate : aggregateAliasToAggregateType.entrySet()) {
String alias = aliasToAggregate.getKey();
AggregateOperator aggregateOperator = null;
Object aliasAggregateOperator = aliasToAggregate.getValue();
Comment thread
jeet1995 marked this conversation as resolved.
Outdated
if (aliasToAggregate.getValue() != null) {
aggregateOperator = AggregateOperator.valueOf(String.valueOf(aliasToAggregate.getValue()));
}
Expand Down
Loading