@@ -2081,7 +2081,11 @@ export abstract class Expression implements ProtoValueSerializable, UserData {
2081
2081
ifAbsent ( elseExpression : unknown ) : Expression ;
2082
2082
2083
2083
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
+ ) ;
2085
2089
}
2086
2090
2087
2091
/**
@@ -2111,9 +2115,40 @@ export abstract class Expression implements ProtoValueSerializable, UserData {
2111
2115
join ( delimiter : string ) : Expression ;
2112
2116
2113
2117
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
+ ) ;
2115
2123
}
2116
2124
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
+ }
2117
2152
2118
2153
// TODO(new-expression): Add new expression method definitions above this line
2119
2154
@@ -6861,7 +6896,11 @@ export function currentTimestamp(): FunctionExpression {
6861
6896
* @return A new Expression representing the error() operation.
6862
6897
*/
6863
6898
export 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
+ ) ;
6865
6904
}
6866
6905
6867
6906
/**
@@ -7391,9 +7430,17 @@ export function ifAbsent(ifFieldName: string, elseExpr: Expression): Expression;
7391
7430
* @param elseValue The value that will be returned if [ifFieldName] is absent.
7392
7431
* @return A new Expression representing the ifAbsent operation.
7393
7432
*/
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
+ ) ;
7397
7444
}
7398
7445
7399
7446
/**
@@ -7422,7 +7469,10 @@ export function join(arrayFieldName: string, delimiter: string): Expression;
7422
7469
* @param delimiterExpression The expression that evaluates to the delimiter string.
7423
7470
* @return A new Expression representing the join operation.
7424
7471
*/
7425
- export function join ( arrayExpression : Expression , delimiterExpression : Expression ) : Expression ;
7472
+ export function join (
7473
+ arrayExpression : Expression ,
7474
+ delimiterExpression : Expression
7475
+ ) : Expression ;
7426
7476
7427
7477
/**
7428
7478
* Creates an expression that joins the elements of an array into a string.
@@ -7436,7 +7486,10 @@ export function join(arrayExpression: Expression, delimiterExpression: Expressio
7436
7486
* @param delimiter The string to use as a delimiter.
7437
7487
* @return A new Expression representing the join operation.
7438
7488
*/
7439
- export function join ( arrayExpression : Expression , delimiter : string ) : Expression ;
7489
+ export function join (
7490
+ arrayExpression : Expression ,
7491
+ delimiter : string
7492
+ ) : Expression ;
7440
7493
7441
7494
/**
7442
7495
* 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
7450
7503
* @param delimiterExpression The expression that evaluates to the delimiter string.
7451
7504
* @return A new Expression representing the join operation.
7452
7505
*/
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 ( ) ;
7456
7575
}
7457
7576
7458
7577
// TODO(new-expression): Add new top-level expression function definitions above this line
0 commit comments