Azure / Azure/azure-sdk-for-java

[Cosmos] Align SUPPORTED_QUERY_FEATURES with .NET SDK — add ListAndSetAggregate, CountIf, HybridSearchSkipOrderByRewrite

Open
#48,661 1 comment 0 reactions 0 assignees View on GitHub
Cosmos
Dominant language
Java
Stars
2.6k
Forks
2.2k
Avg merge
2d 8h
Merged PRs (30d)
178

Description

## Align `SUPPORTED_QUERY_FEATURES` with .NET SDK

### Context

The Java SDK's `QueryPlanRetriever.SUPPORTED_QUERY_FEATURES` advertises **14** query features while the .NET SDK advertises **17**. Three features are missing in Java:

| Missing Feature | .NET Status | Impact |
|-----------------|-------------|--------|
| `ListAndSetAggregate` | ✅ Sent | `MAKELIST`/`MAKESET` queries get suboptimal plans |
| `CountIf` | ✅ Sent | Present in Java's `QueryFeature` enum but **not included** in the features string |
| `HybridSearchSkipOrderByRewrite` | ✅ Sent | Hybrid search uses less efficient ORDER BY plans |

### Current Java feature string
```
Aggregate, CompositeAggregate, MultipleOrderBy, MultipleAggregates, OrderBy, OffsetAndLimit,
Distinct, GroupBy, Top, DCount, NonValueAggregate, NonStreamingOrderBy, HybridSearch, WeightedRankFusion
```

### .NET feature string (superset)
Includes all of the above plus: `ListAndSetAggregate`, `CountIf`, `HybridSearchSkipOrderByRewrite`

### Why this matters now

PR #47759 adds RNTBD header tokens (`SupportedQueryFeatures` 0x00FF, `QueryVersion` 0x0100) to transmit the feature set to the thin client proxy. The proxy uses these to determine which query plan features to include. Customers using the missing features through thin client will get degraded (less optimal) query plans.

### Suggested fix

1. Add `ListAndSetAggregate` and `HybridSearchSkipOrderByRewrite` to `QueryFeature` enum (if not already present)
2. Add `CountIf` to the `SUPPORTED_QUERY_FEATURES` string in `QueryPlanRetriever` (it's already in the enum but not sent)
3. Add `ListAndSetAggregate` and `HybridSearchSkipOrderByRewrite` to the features string
4. Validate each feature against the proxy's query engine behavior

### References

- PR #47759 review discussion: https://github.com/Azure/azure-sdk-for-java/pull/47759#discussion_r3017478769
- Parent tracking issue: #42889

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.