Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 5c99992

Browse files
committed
Fix nested field aggregations
1 parent 5fea6d9 commit 5c99992

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,19 @@ static BooleanExpression toPipelineBooleanExpr(FilterInternal f) {
174174
static AliasedAggregate toPipelineAggregatorTarget(AggregateField f) {
175175
String operator = f.getOperator();
176176
String fieldPath = f.getFieldPath();
177+
String alias = f.getAlias();
178+
if (alias.contains(".")) {
179+
alias = "`" + alias + "`";
180+
}
177181

178182
switch (operator) {
179183
case "sum":
180-
return Field.ofServerPath(fieldPath).sum().as(f.getAlias());
184+
return Field.ofServerPath(fieldPath).sum().as(alias);
181185

182186
case "count":
183-
return countAll().as(f.getAlias());
187+
return countAll().as(alias);
184188
case "average":
185-
return Field.ofServerPath(fieldPath).average().as(f.getAlias());
189+
return Field.ofServerPath(fieldPath).average().as(alias);
186190
default:
187191
// Handle the 'else' case appropriately in your Java code
188192
throw new IllegalArgumentException("Unsupported operator: " + operator);

0 commit comments

Comments
 (0)