@@ -214,6 +214,111 @@ public static AggregateFunction maximum(Expression expression) {
214214 return new AggregateFunction ("maximum" , expression );
215215 }
216216
217+ /**
218+ * Creates an aggregation that finds the first value of a field across multiple stage inputs.
219+ *
220+ * @param fieldName The name of the field to find the first value of.
221+ * @return A new {@link AggregateFunction} representing the first aggregation.
222+ */
223+ @ BetaApi
224+ public static AggregateFunction first (String fieldName ) {
225+ return new AggregateFunction ("first" , fieldName );
226+ }
227+
228+ /**
229+ * Creates an aggregation that finds the first value of an expression across multiple stage
230+ * inputs.
231+ *
232+ * @param expression The expression to find the first value of.
233+ * @return A new {@link AggregateFunction} representing the first aggregation.
234+ */
235+ @ BetaApi
236+ public static AggregateFunction first (Expression expression ) {
237+ return new AggregateFunction ("first" , expression );
238+ }
239+
240+ /**
241+ * Creates an aggregation that finds the last value of a field across multiple stage inputs.
242+ *
243+ * @param fieldName The name of the field to find the last value of.
244+ * @return A new {@link AggregateFunction} representing the last aggregation.
245+ */
246+ @ BetaApi
247+ public static AggregateFunction last (String fieldName ) {
248+ return new AggregateFunction ("last" , fieldName );
249+ }
250+
251+ /**
252+ * Creates an aggregation that finds the last value of an expression across multiple stage inputs.
253+ *
254+ * @param expression The expression to find the last value of.
255+ * @return A new {@link AggregateFunction} representing the last aggregation.
256+ */
257+ @ BetaApi
258+ public static AggregateFunction last (Expression expression ) {
259+ return new AggregateFunction ("last" , expression );
260+ }
261+
262+ /**
263+ * Creates an aggregation that collects all values of a field across multiple stage inputs into an
264+ * array.
265+ *
266+ * <p>If the expression resolves to an absent value, it is converted to `null`. The order of
267+ * elements in the output array is not stable and shouldn't be relied upon.
268+ *
269+ * @param fieldName The name of the field to collect values from.
270+ * @return A new {@link AggregateFunction} representing the array_agg aggregation.
271+ */
272+ @ BetaApi
273+ public static AggregateFunction arrayAgg (String fieldName ) {
274+ return new AggregateFunction ("array_agg" , fieldName );
275+ }
276+
277+ /**
278+ * Creates an aggregation that collects all values of an expression across multiple stage inputs
279+ * into an array.
280+ *
281+ * <p>If the expression resolves to an absent value, it is converted to `null`. The order of
282+ * elements in the output array is not stable and shouldn't be relied upon.
283+ *
284+ * @param expression The expression to collect values from.
285+ * @return A new {@link AggregateFunction} representing the array_agg aggregation.
286+ */
287+ @ BetaApi
288+ public static AggregateFunction arrayAgg (Expression expression ) {
289+ return new AggregateFunction ("array_agg" , expression );
290+ }
291+
292+ /**
293+ * Creates an aggregation that collects all distinct values of a field across multiple stage
294+ * inputs into an array.
295+ *
296+ * <p>If the expression resolves to an absent value, it is converted to `null`. The order of
297+ * elements in the output array is not stable and shouldn't be relied upon.
298+ *
299+ * @param fieldName The name of the field to collect values from.
300+ * @return A new {@link AggregateFunction} representing the array_agg_distinct aggregation.
301+ */
302+ @ BetaApi
303+ public static AggregateFunction arrayAggDistinct (String fieldName ) {
304+ return new AggregateFunction ("array_agg_distinct" , fieldName );
305+ }
306+
307+ /**
308+ * Creates an aggregation that collects all distinct values of an expression across multiple stage
309+ * inputs into an array.
310+ *
311+ * <p>If the expression resolves to an absent value, it is converted to `null`. The order of
312+ * elements in the output array is not stable and shouldn't be relied upon.
313+ *
314+ * @param expression The expression to collect values from.
315+ * @return A new {@link AggregateFunction} representing the array_agg_distinct aggregation.
316+ */
317+ @ BetaApi
318+ public static AggregateFunction arrayAggDistinct (Expression expression ) {
319+ return new AggregateFunction ("array_agg_distinct" , expression );
320+ }
321+
217322 /**
218323 * Assigns an alias to this aggregate.
219324 *
0 commit comments