Skip to content

Commit d099d65

Browse files
aditishree1Aditishree .
andauthored
[cosmos] Fix CountIf aggregation and add full-text query tests (#35054)
### Packages impacted by this PR @azure/cosmos ### Issues associated with this PR ### Describe the problem that is addressed by this PR This PR - 1. adds test cases for full text search. 2. Fixes COUNTIF aggregation to use `CountAggregator` instead of `StaticValueAggregator`. This ensures that partial results from multiple partitions or batches are correctly summed, producing accurate results for COUNTIF queries. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary) --------- Co-authored-by: Aditishree . <adlnu@microsoft.com>
1 parent f4ebe83 commit d099d65

5 files changed

Lines changed: 418 additions & 6 deletions

File tree

sdk/cosmosdb/cosmos/review/cosmos.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface Agent {
2727
}
2828

2929
// @public (undocumented)
30-
export type AggregateType = "Average" | "Count" | "Max" | "Min" | "Sum" | "MakeSet" | "MakeList";
30+
export type AggregateType = "Average" | "Count" | "Max" | "Min" | "Sum" | "MakeSet" | "MakeList" | "CountIf";
3131

3232
// @public
3333
export class AzureKeyVaultEncryptionKeyResolver implements EncryptionKeyResolver {

sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export function createAggregator(
2323
case "Average":
2424
return new AverageAggregator();
2525
case "Count":
26+
case "CountIf":
2627
return new CountAggregator();
2728
case "Max":
2829
return new MaxAggregator();

sdk/cosmosdb/cosmos/src/request/ErrorResponse.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,15 @@ export interface HybridSearchQueryInfo {
8888

8989
export type GroupByExpressions = string[];
9090

91-
export type AggregateType = "Average" | "Count" | "Max" | "Min" | "Sum" | "MakeSet" | "MakeList";
91+
export type AggregateType =
92+
| "Average"
93+
| "Count"
94+
| "Max"
95+
| "Min"
96+
| "Sum"
97+
| "MakeSet"
98+
| "MakeList"
99+
| "CountIf";
92100

93101
export interface GroupByAliasToAggregateType {
94102
[key: string]: AggregateType;

sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,7 @@ async function executeQueryAndVerifyOrder(
559559
assert.equal(count, size);
560560
}
561561

562-
// Skipping these tests as they are not supported by public emulator
563-
describe.skip("Full text search feature", async () => {
562+
describe("Full text search feature", async () => {
564563
let database: Database;
565564

566565
beforeAll(async () => {

0 commit comments

Comments
 (0)