@@ -1484,6 +1484,80 @@ export abstract class Expression
14841484 return new AggregateFunction ( 'maximum' , [ this ] ) ;
14851485 }
14861486
1487+ /**
1488+ * @beta
1489+ * Creates an aggregation that finds the first value of an expression across multiple stage inputs.
1490+ *
1491+ * @example
1492+ * ```typescript
1493+ * // Find the first value of the 'rating' field
1494+ * field("rating").first().as("firstRating");
1495+ * ```
1496+ *
1497+ * @returns A new `AggregateFunction` representing the 'first' aggregation.
1498+ */
1499+ first ( ) : AggregateFunction {
1500+ return new AggregateFunction ( 'first' , [ this ] ) ;
1501+ }
1502+
1503+ /**
1504+ * @beta
1505+ * Creates an aggregation that finds the last value of an expression across multiple stage inputs.
1506+ *
1507+ * @example
1508+ * ```typescript
1509+ * // Find the last value of the 'rating' field
1510+ * field("rating").last().as("lastRating");
1511+ * ```
1512+ *
1513+ * @returns A new `AggregateFunction` representing the 'last' aggregation.
1514+ */
1515+ last ( ) : AggregateFunction {
1516+ return new AggregateFunction ( 'last' , [ this ] ) ;
1517+ }
1518+
1519+ /**
1520+ * @beta
1521+ * Creates an aggregation that collects all values of an expression across multiple stage inputs
1522+ * into an array.
1523+ *
1524+ * @remarks
1525+ * If the expression resolves to an absent value, it is converted to `null`.
1526+ * The order of elements in the output array is not stable and shouldn't be relied upon.
1527+ *
1528+ * @example
1529+ * ```typescript
1530+ * // Collect all tags from books into an array
1531+ * field("tags").arrayAgg().as("allTags");
1532+ * ```
1533+ *
1534+ * @returns A new `AggregateFunction` representing the 'array_agg' aggregation.
1535+ */
1536+ arrayAgg ( ) : AggregateFunction {
1537+ return new AggregateFunction ( 'array_agg' , [ this ] ) ;
1538+ }
1539+
1540+ /**
1541+ * @beta
1542+ * Creates an aggregation that collects all distinct values of an expression across multiple stage
1543+ * inputs into an array.
1544+ *
1545+ * @remarks
1546+ * If the expression resolves to an absent value, it is converted to `null`.
1547+ * The order of elements in the output array is not stable and shouldn't be relied upon.
1548+ *
1549+ * @example
1550+ * ```typescript
1551+ * // Collect all distinct tags from books into an array
1552+ * field("tags").arrayAggDistinct().as("allDistinctTags");
1553+ * ```
1554+ *
1555+ * @returns A new `AggregateFunction` representing the 'array_agg_distinct' aggregation.
1556+ */
1557+ arrayAggDistinct ( ) : AggregateFunction {
1558+ return new AggregateFunction ( 'array_agg_distinct' , [ this ] ) ;
1559+ }
1560+
14871561 /**
14881562 * @beta
14891563 * Creates an aggregation that counts the number of distinct values of the expression or field.
@@ -6915,6 +6989,162 @@ export function maximum(value: Expression | string): AggregateFunction {
69156989 return fieldOrExpression ( value ) . maximum ( ) ;
69166990}
69176991
6992+ /**
6993+ * @beta
6994+ * Creates an aggregation that finds the first value of an expression across multiple stage
6995+ * inputs.
6996+ *
6997+ * @example
6998+ * ```typescript
6999+ * // Find the first value of the 'rating' field
7000+ * first(field("rating")).as("firstRating");
7001+ * ```
7002+ *
7003+ * @param expression The expression to find the first value of.
7004+ * @returns A new `AggregateFunction` representing the 'first' aggregation.
7005+ */
7006+ export function first ( expression : Expression ) : AggregateFunction ;
7007+
7008+ /**
7009+ * @beta
7010+ * Creates an aggregation that finds the first value of a field across multiple stage inputs.
7011+ *
7012+ * @example
7013+ * ```typescript
7014+ * // Find the first value of the 'rating' field
7015+ * first("rating").as("firstRating");
7016+ * ```
7017+ *
7018+ * @param fieldName The name of the field to find the first value of.
7019+ * @returns A new `AggregateFunction` representing the 'first' aggregation.
7020+ */
7021+ export function first ( fieldName : string ) : AggregateFunction ;
7022+ export function first ( value : Expression | string ) : AggregateFunction {
7023+ return fieldOrExpression ( value ) . first ( ) ;
7024+ }
7025+
7026+ /**
7027+ * @beta
7028+ * Creates an aggregation that finds the last value of an expression across multiple stage
7029+ * inputs.
7030+ *
7031+ * @example
7032+ * ```typescript
7033+ * // Find the last value of the 'rating' field
7034+ * last(field("rating")).as("lastRating");
7035+ * ```
7036+ *
7037+ * @param expression The expression to find the last value of.
7038+ * @returns A new `AggregateFunction` representing the 'last' aggregation.
7039+ */
7040+ export function last ( expression : Expression ) : AggregateFunction ;
7041+
7042+ /**
7043+ * @beta
7044+ * Creates an aggregation that finds the last value of a field across multiple stage inputs.
7045+ *
7046+ * @example
7047+ * ```typescript
7048+ * // Find the last value of the 'rating' field
7049+ * last("rating").as("lastRating");
7050+ * ```
7051+ *
7052+ * @param fieldName The name of the field to find the last value of.
7053+ * @returns A new `AggregateFunction` representing the 'last' aggregation.
7054+ */
7055+ export function last ( fieldName : string ) : AggregateFunction ;
7056+ export function last ( value : Expression | string ) : AggregateFunction {
7057+ return fieldOrExpression ( value ) . last ( ) ;
7058+ }
7059+
7060+ /**
7061+ * @beta
7062+ * Creates an aggregation that collects all values of an expression across multiple stage
7063+ * inputs into an array.
7064+ *
7065+ * @remarks
7066+ * If the expression resolves to an absent value, it is converted to `null`.
7067+ * The order of elements in the output array is not stable and shouldn't be relied upon.
7068+ *
7069+ * @example
7070+ * ```typescript
7071+ * // Collect all tags from books into an array
7072+ * arrayAgg(field("tags")).as("allTags");
7073+ * ```
7074+ *
7075+ * @param expression The expression to collect values from.
7076+ * @returns A new `AggregateFunction` representing the 'array_agg' aggregation.
7077+ */
7078+ export function arrayAgg ( expression : Expression ) : AggregateFunction ;
7079+
7080+ /**
7081+ * @beta
7082+ * Creates an aggregation that collects all values of a field across multiple stage inputs
7083+ * into an array.
7084+ *
7085+ * @remarks
7086+ * If the expression resolves to an absent value, it is converted to `null`.
7087+ * The order of elements in the output array is not stable and shouldn't be relied upon.
7088+ *
7089+ * @example
7090+ * ```typescript
7091+ * // Collect all tags from books into an array
7092+ * arrayAgg("tags").as("allTags");
7093+ * ```
7094+ *
7095+ * @param fieldName The name of the field to collect values from.
7096+ * @returns A new `AggregateFunction` representing the 'array_agg' aggregation.
7097+ */
7098+ export function arrayAgg ( fieldName : string ) : AggregateFunction ;
7099+ export function arrayAgg ( value : Expression | string ) : AggregateFunction {
7100+ return fieldOrExpression ( value ) . arrayAgg ( ) ;
7101+ }
7102+
7103+ /**
7104+ * @beta
7105+ * Creates an aggregation that collects all distinct values of an expression across multiple stage
7106+ * inputs into an array.
7107+ *
7108+ * @remarks
7109+ * If the expression resolves to an absent value, it is converted to `null`.
7110+ * The order of elements in the output array is not stable and shouldn't be relied upon.
7111+ *
7112+ * @example
7113+ * ```typescript
7114+ * // Collect all distinct tags from books into an array
7115+ * arrayAggDistinct(field("tags")).as("allDistinctTags");
7116+ * ```
7117+ *
7118+ * @param expression The expression to collect values from.
7119+ * @returns A new `AggregateFunction` representing the 'array_agg_distinct' aggregation.
7120+ */
7121+ export function arrayAggDistinct ( expression : Expression ) : AggregateFunction ;
7122+
7123+ /**
7124+ * @beta
7125+ * Creates an aggregation that collects all distinct values of a field across multiple stage inputs
7126+ * into an array.
7127+ *
7128+ * @remarks
7129+ * If the expression resolves to an absent value, it is converted to `null`.
7130+ * The order of elements in the output array is not stable and shouldn't be relied upon.
7131+ *
7132+ * @example
7133+ * ```typescript
7134+ * // Collect all distinct tags from books into an array
7135+ * arrayAggDistinct("tags").as("allDistinctTags");
7136+ * ```
7137+ *
7138+ * @param fieldName The name of the field to collect values from.
7139+ * @returns A new `AggregateFunction` representing the 'array_agg_distinct' aggregation.
7140+ */
7141+ export function arrayAggDistinct ( fieldName : string ) : AggregateFunction ;
7142+ export function arrayAggDistinct (
7143+ value : Expression | string ,
7144+ ) : AggregateFunction {
7145+ return fieldOrExpression ( value ) . arrayAggDistinct ( ) ;
7146+ }
7147+
69187148/**
69197149 * @beta
69207150 * Calculates the Cosine distance between a field's vector value and a literal vector value.
0 commit comments