@@ -2081,7 +2081,11 @@ export abstract class Expression implements ProtoValueSerializable, UserData {
20812081 ifAbsent ( elseExpression : unknown ) : Expression ;
20822082
20832083 ifAbsent ( elseValueOrExpression : Expression | unknown ) : Expression {
2084- return new FunctionExpression ( 'if_absent' , [ this , valueToDefaultExpr ( elseValueOrExpression ) ] , 'ifAbsent' ) ;
2084+ return new FunctionExpression (
2085+ 'if_absent' ,
2086+ [ this , valueToDefaultExpr ( elseValueOrExpression ) ] ,
2087+ 'ifAbsent'
2088+ ) ;
20852089 }
20862090
20872091 /**
@@ -2111,9 +2115,40 @@ export abstract class Expression implements ProtoValueSerializable, UserData {
21112115 join ( delimiter : string ) : Expression ;
21122116
21132117 join ( delimeterValueOrExpression : string | Expression ) : Expression {
2114- return new FunctionExpression ( 'join' , [ this , valueToDefaultExpr ( delimeterValueOrExpression ) ] , 'join' ) ;
2118+ return new FunctionExpression (
2119+ 'join' ,
2120+ [ this , valueToDefaultExpr ( delimeterValueOrExpression ) ] ,
2121+ 'join'
2122+ ) ;
21152123 }
21162124
2125+ /**
2126+ * Creates an expression that computes the base-10 logarithm of a numeric value.
2127+ *
2128+ * ```typescript
2129+ * // Compute the base-10 logarithm of the 'value' field.
2130+ * field("value").log10();
2131+ * ```
2132+ *
2133+ * @return A new {@code Expr} representing the base-10 logarithm of the numeric value.
2134+ */
2135+ log10 ( ) : FunctionExpression {
2136+ return new FunctionExpression ( 'log10' , [ this ] ) ;
2137+ }
2138+
2139+ /**
2140+ * Creates an expression that computes the sum of the elements in an array.
2141+ *
2142+ * ```typescript
2143+ * // Compute the sum of the elements in the 'scores' field.
2144+ * field("scores").arraySum();
2145+ * ```
2146+ *
2147+ * @return A new {@code Expr} representing the sum of the elements in the array.
2148+ */
2149+ arraySum ( ) : FunctionExpression {
2150+ return new FunctionExpression ( 'sum' , [ this ] ) ;
2151+ }
21172152
21182153 // TODO(new-expression): Add new expression method definitions above this line
21192154
@@ -6861,7 +6896,11 @@ export function currentTimestamp(): FunctionExpression {
68616896 * @return A new Expression representing the error() operation.
68626897 */
68636898export function error ( message : string ) : Expression {
6864- return new FunctionExpression ( 'error' , [ constant ( message ) ] , 'currentTimestamp' ) ;
6899+ return new FunctionExpression (
6900+ 'error' ,
6901+ [ constant ( message ) ] ,
6902+ 'currentTimestamp'
6903+ ) ;
68656904}
68666905
68676906/**
@@ -7391,9 +7430,17 @@ export function ifAbsent(ifFieldName: string, elseExpr: Expression): Expression;
73917430 * @param elseValue The value that will be returned if [ifFieldName] is absent.
73927431 * @return A new Expression representing the ifAbsent operation.
73937432 */
7394- export function ifAbsent ( ifFieldName : string | Expression , elseValue : Expression | unknown ) : Expression ;
7395- export function ifAbsent ( fieldNameOrExpression : string | Expression , elseValue : Expression | unknown ) : Expression {
7396- return fieldOrExpression ( fieldNameOrExpression ) . ifAbsent ( valueToDefaultExpr ( elseValue ) ) ;
7433+ export function ifAbsent (
7434+ ifFieldName : string | Expression ,
7435+ elseValue : Expression | unknown
7436+ ) : Expression ;
7437+ export function ifAbsent (
7438+ fieldNameOrExpression : string | Expression ,
7439+ elseValue : Expression | unknown
7440+ ) : Expression {
7441+ return fieldOrExpression ( fieldNameOrExpression ) . ifAbsent (
7442+ valueToDefaultExpr ( elseValue )
7443+ ) ;
73977444}
73987445
73997446/**
@@ -7422,7 +7469,10 @@ export function join(arrayFieldName: string, delimiter: string): Expression;
74227469 * @param delimiterExpression The expression that evaluates to the delimiter string.
74237470 * @return A new Expression representing the join operation.
74247471 */
7425- export function join ( arrayExpression : Expression , delimiterExpression : Expression ) : Expression ;
7472+ export function join (
7473+ arrayExpression : Expression ,
7474+ delimiterExpression : Expression
7475+ ) : Expression ;
74267476
74277477/**
74287478 * Creates an expression that joins the elements of an array into a string.
@@ -7436,7 +7486,10 @@ export function join(arrayExpression: Expression, delimiterExpression: Expressio
74367486 * @param delimiter The string to use as a delimiter.
74377487 * @return A new Expression representing the join operation.
74387488 */
7439- export function join ( arrayExpression : Expression , delimiter : string ) : Expression ;
7489+ export function join (
7490+ arrayExpression : Expression ,
7491+ delimiter : string
7492+ ) : Expression ;
74407493
74417494/**
74427495 * Creates an expression that joins the elements of an array into a string.
@@ -7450,9 +7503,75 @@ export function join(arrayExpression: Expression, delimiter: string): Expression
74507503 * @param delimiterExpression The expression that evaluates to the delimiter string.
74517504 * @return A new Expression representing the join operation.
74527505 */
7453- export function join ( arrayFieldName : string , delimiterExpression : Expression ) : Expression ;
7454- export function join ( fieldNameOrExpression : string | Expression , delimiterValueOrExpression : Expression | string ) : Expression {
7455- return fieldOrExpression ( fieldNameOrExpression ) . join ( valueToDefaultExpr ( delimiterValueOrExpression ) ) ;
7506+ export function join (
7507+ arrayFieldName : string ,
7508+ delimiterExpression : Expression
7509+ ) : Expression ;
7510+ export function join (
7511+ fieldNameOrExpression : string | Expression ,
7512+ delimiterValueOrExpression : Expression | string
7513+ ) : Expression {
7514+ return fieldOrExpression ( fieldNameOrExpression ) . join (
7515+ valueToDefaultExpr ( delimiterValueOrExpression )
7516+ ) ;
7517+ }
7518+
7519+ /**
7520+ * Creates an expression that computes the base-10 logarithm of a numeric value.
7521+ *
7522+ * ```typescript
7523+ * // Compute the base-10 logarithm of the 'value' field.
7524+ * log10("value");
7525+ * ```
7526+ *
7527+ * @param fieldName The name of the field to compute the base-10 logarithm of.
7528+ * @return A new `Expr` representing the base-10 logarithm of the numeric value.
7529+ */
7530+ export function log10 ( fieldName : string ) : FunctionExpression ;
7531+
7532+ /**
7533+ * Creates an expression that computes the base-10 logarithm of a numeric value.
7534+ *
7535+ * ```typescript
7536+ * // Compute the base-10 logarithm of the 'value' field.
7537+ * log10(field("value"));
7538+ * ```
7539+ *
7540+ * @param expression An expression evaluating to a numeric value, which the base-10 logarithm will be computed for.
7541+ * @return A new `Expr` representing the base-10 logarithm of the numeric value.
7542+ */
7543+ export function log10 ( expression : Expression ) : FunctionExpression ;
7544+ export function log10 ( expr : Expression | string ) : FunctionExpression {
7545+ return fieldOrExpression ( expr ) . log10 ( ) ;
7546+ }
7547+
7548+ /**
7549+ * Creates an expression that computes the sum of the elements in an array.
7550+ *
7551+ * ```typescript
7552+ * // Compute the sum of the elements in the 'scores' field.
7553+ * arraySum("scores");
7554+ * ```
7555+ *
7556+ * @param fieldName The name of the field to compute the sum of.
7557+ * @return A new `Expr` representing the sum of the elements in the array.
7558+ */
7559+ export function arraySum ( fieldName : string ) : FunctionExpression ;
7560+
7561+ /**
7562+ * Creates an expression that computes the sum of the elements in an array.
7563+ *
7564+ * ```typescript
7565+ * // Compute the sum of the elements in the 'scores' field.
7566+ * arraySum(field("scores"));
7567+ * ```
7568+ *
7569+ * @param expression An expression evaluating to a numeric array, which the sum will be computed for.
7570+ * @return A new `Expr` representing the sum of the elements in the array.
7571+ */
7572+ export function arraySum ( expression : Expression ) : FunctionExpression ;
7573+ export function arraySum ( expr : Expression | string ) : FunctionExpression {
7574+ return fieldOrExpression ( expr ) . arraySum ( ) ;
74567575}
74577576
74587577// TODO(new-expression): Add new top-level expression function definitions above this line
0 commit comments