Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit eb02ca4

Browse files
committedMay 7, 2025·
More expression work
1 parent 891cefd commit eb02ca4

File tree

2 files changed

+123
-41
lines changed

2 files changed

+123
-41
lines changed
 

‎firebase-firestore/api.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,28 +1176,28 @@ package com.google.firebase.firestore.pipeline {
11761176
method public final com.google.firebase.firestore.pipeline.Expr timestampSub(String unit, double amount);
11771177
method public static final com.google.firebase.firestore.pipeline.Expr timestampSub(String fieldName, String unit, double amount);
11781178
method public final com.google.firebase.firestore.pipeline.Expr timestampToUnixMicros();
1179-
method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixMicros(com.google.firebase.firestore.pipeline.Expr input);
1179+
method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixMicros(com.google.firebase.firestore.pipeline.Expr expr);
11801180
method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixMicros(String fieldName);
11811181
method public final com.google.firebase.firestore.pipeline.Expr timestampToUnixMillis();
1182-
method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixMillis(com.google.firebase.firestore.pipeline.Expr input);
1182+
method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixMillis(com.google.firebase.firestore.pipeline.Expr expr);
11831183
method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixMillis(String fieldName);
11841184
method public final com.google.firebase.firestore.pipeline.Expr timestampToUnixSeconds();
1185-
method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixSeconds(com.google.firebase.firestore.pipeline.Expr input);
1185+
method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixSeconds(com.google.firebase.firestore.pipeline.Expr expr);
11861186
method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixSeconds(String fieldName);
11871187
method public final com.google.firebase.firestore.pipeline.Expr toLower();
1188-
method public static final com.google.firebase.firestore.pipeline.Expr toLower(com.google.firebase.firestore.pipeline.Expr expr);
1188+
method public static final com.google.firebase.firestore.pipeline.Expr toLower(com.google.firebase.firestore.pipeline.Expr stringExpression);
11891189
method public static final com.google.firebase.firestore.pipeline.Expr toLower(String fieldName);
11901190
method public final com.google.firebase.firestore.pipeline.Expr toUpper();
1191-
method public static final com.google.firebase.firestore.pipeline.Expr toUpper(com.google.firebase.firestore.pipeline.Expr expr);
1191+
method public static final com.google.firebase.firestore.pipeline.Expr toUpper(com.google.firebase.firestore.pipeline.Expr stringExpression);
11921192
method public static final com.google.firebase.firestore.pipeline.Expr toUpper(String fieldName);
11931193
method public final com.google.firebase.firestore.pipeline.Expr trim();
1194-
method public static final com.google.firebase.firestore.pipeline.Expr trim(com.google.firebase.firestore.pipeline.Expr expr);
1194+
method public static final com.google.firebase.firestore.pipeline.Expr trim(com.google.firebase.firestore.pipeline.Expr stringExpression);
11951195
method public static final com.google.firebase.firestore.pipeline.Expr trim(String fieldName);
11961196
method public final com.google.firebase.firestore.pipeline.Expr unixMicrosToTimestamp();
11971197
method public static final com.google.firebase.firestore.pipeline.Expr unixMicrosToTimestamp(com.google.firebase.firestore.pipeline.Expr input);
11981198
method public static final com.google.firebase.firestore.pipeline.Expr unixMicrosToTimestamp(String fieldName);
11991199
method public final com.google.firebase.firestore.pipeline.Expr unixMillisToTimestamp();
1200-
method public static final com.google.firebase.firestore.pipeline.Expr unixMillisToTimestamp(com.google.firebase.firestore.pipeline.Expr input);
1200+
method public static final com.google.firebase.firestore.pipeline.Expr unixMillisToTimestamp(com.google.firebase.firestore.pipeline.Expr expr);
12011201
method public static final com.google.firebase.firestore.pipeline.Expr unixMillisToTimestamp(String fieldName);
12021202
method public final com.google.firebase.firestore.pipeline.Expr unixSecondsToTimestamp();
12031203
method public static final com.google.firebase.firestore.pipeline.Expr unixSecondsToTimestamp(com.google.firebase.firestore.pipeline.Expr input);
@@ -1444,21 +1444,21 @@ package com.google.firebase.firestore.pipeline {
14441444
method public com.google.firebase.firestore.pipeline.Expr timestampSub(com.google.firebase.firestore.pipeline.Expr timestamp, String unit, double amount);
14451445
method public com.google.firebase.firestore.pipeline.Expr timestampSub(String fieldName, com.google.firebase.firestore.pipeline.Expr unit, com.google.firebase.firestore.pipeline.Expr amount);
14461446
method public com.google.firebase.firestore.pipeline.Expr timestampSub(String fieldName, String unit, double amount);
1447-
method public com.google.firebase.firestore.pipeline.Expr timestampToUnixMicros(com.google.firebase.firestore.pipeline.Expr input);
1447+
method public com.google.firebase.firestore.pipeline.Expr timestampToUnixMicros(com.google.firebase.firestore.pipeline.Expr expr);
14481448
method public com.google.firebase.firestore.pipeline.Expr timestampToUnixMicros(String fieldName);
1449-
method public com.google.firebase.firestore.pipeline.Expr timestampToUnixMillis(com.google.firebase.firestore.pipeline.Expr input);
1449+
method public com.google.firebase.firestore.pipeline.Expr timestampToUnixMillis(com.google.firebase.firestore.pipeline.Expr expr);
14501450
method public com.google.firebase.firestore.pipeline.Expr timestampToUnixMillis(String fieldName);
1451-
method public com.google.firebase.firestore.pipeline.Expr timestampToUnixSeconds(com.google.firebase.firestore.pipeline.Expr input);
1451+
method public com.google.firebase.firestore.pipeline.Expr timestampToUnixSeconds(com.google.firebase.firestore.pipeline.Expr expr);
14521452
method public com.google.firebase.firestore.pipeline.Expr timestampToUnixSeconds(String fieldName);
1453-
method public com.google.firebase.firestore.pipeline.Expr toLower(com.google.firebase.firestore.pipeline.Expr expr);
1453+
method public com.google.firebase.firestore.pipeline.Expr toLower(com.google.firebase.firestore.pipeline.Expr stringExpression);
14541454
method public com.google.firebase.firestore.pipeline.Expr toLower(String fieldName);
1455-
method public com.google.firebase.firestore.pipeline.Expr toUpper(com.google.firebase.firestore.pipeline.Expr expr);
1455+
method public com.google.firebase.firestore.pipeline.Expr toUpper(com.google.firebase.firestore.pipeline.Expr stringExpression);
14561456
method public com.google.firebase.firestore.pipeline.Expr toUpper(String fieldName);
1457-
method public com.google.firebase.firestore.pipeline.Expr trim(com.google.firebase.firestore.pipeline.Expr expr);
1457+
method public com.google.firebase.firestore.pipeline.Expr trim(com.google.firebase.firestore.pipeline.Expr stringExpression);
14581458
method public com.google.firebase.firestore.pipeline.Expr trim(String fieldName);
14591459
method public com.google.firebase.firestore.pipeline.Expr unixMicrosToTimestamp(com.google.firebase.firestore.pipeline.Expr input);
14601460
method public com.google.firebase.firestore.pipeline.Expr unixMicrosToTimestamp(String fieldName);
1461-
method public com.google.firebase.firestore.pipeline.Expr unixMillisToTimestamp(com.google.firebase.firestore.pipeline.Expr input);
1461+
method public com.google.firebase.firestore.pipeline.Expr unixMillisToTimestamp(com.google.firebase.firestore.pipeline.Expr expr);
14621462
method public com.google.firebase.firestore.pipeline.Expr unixMillisToTimestamp(String fieldName);
14631463
method public com.google.firebase.firestore.pipeline.Expr unixSecondsToTimestamp(com.google.firebase.firestore.pipeline.Expr input);
14641464
method public com.google.firebase.firestore.pipeline.Expr unixSecondsToTimestamp(String fieldName);

‎firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/expressions.kt

Lines changed: 109 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,28 +1641,54 @@ abstract class Expr internal constructor() {
16411641
fun endsWith(fieldName: String, suffix: String): BooleanExpr =
16421642
BooleanExpr("ends_with", fieldName, suffix)
16431643

1644-
/** @return A new [Expr] representing the toLower operation. */
1645-
@JvmStatic fun toLower(expr: Expr): Expr = FunctionExpr("to_lower", expr)
1646-
1647-
/** @return A new [Expr] representing the toLower operation. */
1644+
/**
1645+
* Creates an expression that converts a string expression to lowercase.
1646+
*
1647+
* @param stringExpression The expression representing the string to convert to lowercase.
1648+
* @return A new [Expr] representing the lowercase string.
1649+
*/
16481650
@JvmStatic
1649-
fun toLower(
1650-
fieldName: String,
1651-
): Expr = FunctionExpr("to_lower", fieldName)
1651+
fun toLower(stringExpression: Expr): Expr = FunctionExpr("to_lower", stringExpression)
16521652

1653-
/** @return A new [Expr] representing the toUpper operation. */
1654-
@JvmStatic fun toUpper(expr: Expr): Expr = FunctionExpr("to_upper", expr)
1653+
/**
1654+
* Creates an expression that converts a string field to lowercase.
1655+
*
1656+
* @param fieldName The name of the field containing the string to convert to lowercase.
1657+
* @return A new [Expr] representing the lowercase string.
1658+
*/
1659+
@JvmStatic fun toLower(fieldName: String): Expr = FunctionExpr("to_lower", fieldName)
16551660

1656-
/** @return A new [Expr] representing the toUpper operation. */
1661+
/**
1662+
* Creates an expression that converts a string expression to uppercase.
1663+
*
1664+
* @param stringExpression The expression representing the string to convert to uppercase.
1665+
* @return A new [Expr] representing the lowercase string.
1666+
*/
16571667
@JvmStatic
1658-
fun toUpper(
1659-
fieldName: String,
1660-
): Expr = FunctionExpr("to_upper", fieldName)
1668+
fun toUpper(stringExpression: Expr): Expr = FunctionExpr("to_upper", stringExpression)
1669+
1670+
/**
1671+
* Creates an expression that converts a string field to uppercase.
1672+
*
1673+
* @param fieldName The name of the field containing the string to convert to uppercase.
1674+
* @return A new [Expr] representing the lowercase string.
1675+
*/
1676+
@JvmStatic fun toUpper(fieldName: String): Expr = FunctionExpr("to_upper", fieldName)
16611677

1662-
/** @return A new [Expr] representing the trim operation. */
1663-
@JvmStatic fun trim(expr: Expr): Expr = FunctionExpr("trim", expr)
1678+
/**
1679+
* Creates an expression that removes leading and trailing whitespace from a string expression.
1680+
*
1681+
* @param stringExpression The expression representing the string to trim.
1682+
* @return A new [Expr] representing the trimmed string.
1683+
*/
1684+
@JvmStatic fun trim(stringExpression: Expr): Expr = FunctionExpr("trim", stringExpression)
16641685

1665-
/** @return A new [Expr] representing the trim operation. */
1686+
/**
1687+
* Creates an expression that removes leading and trailing whitespace from a string field.
1688+
*
1689+
* @param fieldName The name of the field containing the string to trim.
1690+
* @return A new [Expr] representing the trimmed string.
1691+
*/
16661692
@JvmStatic fun trim(fieldName: String): Expr = FunctionExpr("trim", fieldName)
16671693

16681694
/**
@@ -2022,29 +2048,52 @@ abstract class Expr internal constructor() {
20222048
fun unixMicrosToTimestamp(fieldName: String): Expr =
20232049
FunctionExpr("unix_micros_to_timestamp", fieldName)
20242050

2025-
/** @return A new [Expr] representing the timestampToUnixMicros operation. */
2051+
/**
2052+
* Creates an expression that converts a timestamp expression to the number of microseconds
2053+
* since the Unix epoch (1970-01-01 00:00:00 UTC).
2054+
*
2055+
* @param expr The expression representing the timestamp.
2056+
* @return A new [Expr] representing the number of microseconds since epoch.
2057+
*/
20262058
@JvmStatic
2027-
fun timestampToUnixMicros(input: Expr): Expr = FunctionExpr("timestamp_to_unix_micros", input)
2059+
fun timestampToUnixMicros(expr: Expr): Expr = FunctionExpr("timestamp_to_unix_micros", expr)
20282060

2029-
/** @return A new [Expr] representing the timestampToUnixMicros operation. */
2061+
/**
2062+
* Creates an expression that converts a timestamp field to the number of microseconds since the
2063+
* Unix epoch (1970-01-01 00:00:00 UTC).
2064+
*
2065+
* @param fieldName The name of the field that contains the timestamp.
2066+
* @return A new [Expr] representing the number of microseconds since epoch.
2067+
*/
20302068
@JvmStatic
20312069
fun timestampToUnixMicros(fieldName: String): Expr =
20322070
FunctionExpr("timestamp_to_unix_micros", fieldName)
20332071

2034-
/** @return A new [Expr] representing the unixMillisToTimestamp operation. */
20352072
@JvmStatic
2036-
fun unixMillisToTimestamp(input: Expr): Expr = FunctionExpr("unix_millis_to_timestamp", input)
2073+
fun unixMillisToTimestamp(expr: Expr): Expr = FunctionExpr("unix_millis_to_timestamp", expr)
20372074

20382075
/** @return A new [Expr] representing the unixMillisToTimestamp operation. */
20392076
@JvmStatic
20402077
fun unixMillisToTimestamp(fieldName: String): Expr =
20412078
FunctionExpr("unix_millis_to_timestamp", fieldName)
20422079

2043-
/** @return A new [Expr] representing the timestampToUnixMillis operation. */
2080+
/**
2081+
* Creates an expression that converts a timestamp expression to the number of milliseconds
2082+
* since the Unix epoch (1970-01-01 00:00:00 UTC).
2083+
*
2084+
* @param expr The expression representing the timestamp.
2085+
* @return A new [Expr] representing the number of milliseconds since epoch.
2086+
*/
20442087
@JvmStatic
2045-
fun timestampToUnixMillis(input: Expr): Expr = FunctionExpr("timestamp_to_unix_millis", input)
2088+
fun timestampToUnixMillis(expr: Expr): Expr = FunctionExpr("timestamp_to_unix_millis", expr)
20462089

2047-
/** @return A new [Expr] representing the timestampToUnixMillis operation. */
2090+
/**
2091+
* Creates an expression that converts a timestamp field to the number of milliseconds since the
2092+
* Unix epoch (1970-01-01 00:00:00 UTC).
2093+
*
2094+
* @param fieldName The name of the field that contains the timestamp.
2095+
* @return A new [Expr] representing the number of milliseconds since epoch.
2096+
*/
20482097
@JvmStatic
20492098
fun timestampToUnixMillis(fieldName: String): Expr =
20502099
FunctionExpr("timestamp_to_unix_millis", fieldName)
@@ -2058,11 +2107,23 @@ abstract class Expr internal constructor() {
20582107
fun unixSecondsToTimestamp(fieldName: String): Expr =
20592108
FunctionExpr("unix_seconds_to_timestamp", fieldName)
20602109

2061-
/** @return A new [Expr] representing the timestampToUnixSeconds operation. */
2110+
/**
2111+
* Creates an expression that converts a timestamp expression to the number of seconds since the
2112+
* Unix epoch (1970-01-01 00:00:00 UTC).
2113+
*
2114+
* @param expr The expression representing the timestamp.
2115+
* @return A new [Expr] representing the number of seconds since epoch.
2116+
*/
20622117
@JvmStatic
2063-
fun timestampToUnixSeconds(input: Expr): Expr = FunctionExpr("timestamp_to_unix_seconds", input)
2118+
fun timestampToUnixSeconds(expr: Expr): Expr = FunctionExpr("timestamp_to_unix_seconds", expr)
20642119

2065-
/** @return A new [Expr] representing the timestampToUnixSeconds operation. */
2120+
/**
2121+
* Creates an expression that converts a timestamp field to the number of seconds since the Unix
2122+
* epoch (1970-01-01 00:00:00 UTC).
2123+
*
2124+
* @param fieldName The name of the field that contains the timestamp.
2125+
* @return A new [Expr] representing the number of seconds since epoch.
2126+
*/
20662127
@JvmStatic
20672128
fun timestampToUnixSeconds(fieldName: String): Expr =
20682129
FunctionExpr("timestamp_to_unix_seconds", fieldName)
@@ -3316,14 +3377,23 @@ abstract class Expr internal constructor() {
33163377
fun endsWith(suffix: String) = Companion.endsWith(this, suffix)
33173378

33183379
/**
3380+
* Creates an expression that converts this string expression to lowercase.
3381+
*
3382+
* @return A new [Expr] representing the lowercase string.
33193383
*/
33203384
fun toLower() = Companion.toLower(this)
33213385

33223386
/**
3387+
* Creates an expression that converts this string expression to uppercase.
3388+
*
3389+
* @return A new [Expr] representing the lowercase string.
33233390
*/
33243391
fun toUpper() = Companion.toUpper(this)
33253392

33263393
/**
3394+
* Creates an expression that removes leading and trailing whitespace from this string expression.
3395+
*
3396+
* @return A new [Expr] representing the trimmed string.
33273397
*/
33283398
fun trim() = Companion.trim(this)
33293399

@@ -3468,6 +3538,10 @@ abstract class Expr internal constructor() {
34683538
fun unixMicrosToTimestamp() = Companion.unixMicrosToTimestamp(this)
34693539

34703540
/**
3541+
* Creates an expression that converts this timestamp expression to the number of microseconds
3542+
* since the Unix epoch (1970-01-01 00:00:00 UTC).
3543+
*
3544+
* @return A new [Expr] representing the number of microseconds since epoch.
34713545
*/
34723546
fun timestampToUnixMicros() = Companion.timestampToUnixMicros(this)
34733547

@@ -3476,6 +3550,10 @@ abstract class Expr internal constructor() {
34763550
fun unixMillisToTimestamp() = Companion.unixMillisToTimestamp(this)
34773551

34783552
/**
3553+
* Creates an expression that converts this timestamp expression to the number of milliseconds
3554+
* since the Unix epoch (1970-01-01 00:00:00 UTC).
3555+
*
3556+
* @return A new [Expr] representing the number of milliseconds since epoch.
34793557
*/
34803558
fun timestampToUnixMillis() = Companion.timestampToUnixMillis(this)
34813559

@@ -3484,6 +3562,10 @@ abstract class Expr internal constructor() {
34843562
fun unixSecondsToTimestamp() = Companion.unixSecondsToTimestamp(this)
34853563

34863564
/**
3565+
* Creates an expression that converts this timestamp expression to the number of seconds since
3566+
* the Unix epoch (1970-01-01 00:00:00 UTC).
3567+
*
3568+
* @return A new [Expr] representing the number of seconds since epoch.
34873569
*/
34883570
fun timestampToUnixSeconds() = Companion.timestampToUnixSeconds(this)
34893571

0 commit comments

Comments
 (0)
Please sign in to comment.