Skip to content

Commit 4cb5ec3

Browse files
authored
Document aggregates and groupings methods (#134533)
1 parent be95996 commit 4cb5ec3

File tree

1 file changed

+16
-0
lines changed
  • x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical

1 file changed

+16
-0
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/Aggregate.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,26 @@ public Aggregate with(LogicalPlan child, List<Expression> newGroupings, List<? e
114114
return new Aggregate(source(), child, newGroupings, newAggregates);
115115
}
116116

117+
/**
118+
* What this aggregation is grouped by. Generally, this corresponds to the {@code BY} clause, even though this command will not output
119+
* those values unless they are also part of the {@link Aggregate#aggregates()}. This enables grouping without outputting the grouping
120+
* keys, and makes it so that an {@link Aggregate}s also acts as a projection.
121+
* <p>
122+
* The actual grouping keys will be extracted from multivalues, so that if the grouping is on {@code mv_field}, and the document has
123+
* {@code mv_field: [1, 2, 2]}, then the document will be part of the groups for both {@code mv_field=1} and {@code mv_field=2} (and
124+
* counted only once in each group).
125+
*/
117126
public List<Expression> groupings() {
118127
return groupings;
119128
}
120129

130+
/**
131+
* The actual aggregates to compute. This includes the grouping keys if they are to be output.
132+
* <p>
133+
* Multivalued grouping keys will be extracted into single values, so that if the grouping is on {@code mv_field}, and the document has
134+
* {@code mv_field: [1, 2, 2]}, then the output will have two corresponding rows, one with {@code mv_field=1} and one with
135+
* {@code mv_field=2}.
136+
*/
121137
public List<? extends NamedExpression> aggregates() {
122138
return aggregates;
123139
}

0 commit comments

Comments
 (0)