Debugging functions

Preview:Firestore in Native mode (with Pipeline operations) for Enterpriseedition is subject to the "Pre-GA Offerings Terms" in the GeneralService Terms section of theService SpecificTerms. You can process personaldata for this feature as outlined in theCloud Data Processing Addendum, subjectto the obligations and restrictions described in the agreement under which youaccess Google Cloud. Pre-GA features are available "as is" and might havelimited support. For more information, see thelaunch stagedescriptions.

Debugging Functions

NameDescription
EXISTSReturnsTRUE if the value is not an absent value
IS_ABSENTReturnsTRUE if the value is an absent value
IF_ABSENTReplaces the value with an expression if it is absent
IS_ERRORCatches and checks if an error has been thrown by the underlying expression
IF_ERRORReplaces the value with an expression if it has thrown an error

EXISTS

Syntax:

exists(value: ANY) -> BOOLEAN

Description:

ReturnsTRUE ifvalue is not the absent value.

Examples:

valueexists(value)
0LTRUE
"foo"TRUE
NULLTRUE
ABSENTFALSE
Node.js
constresult=awaitdb.pipeline().collection("books").select(field("rating").exists().as("hasRating")).execute();

Web

Example:

constresult=awaitexecute(db.pipeline().collection("books").select(field("rating").exists().as("hasRating")));
Swift
letresult=tryawaitdb.pipeline().collection("books").select([Field("rating").exists().as("hasRating")]).execute()

Kotlin

Example:

valresult=db.pipeline().collection("books").select(field("rating").exists().alias("hasRating")).execute()

Java

Example:

Task<Pipeline.Snapshot>result=db.pipeline().collection("books").select(field("rating").exists().alias("hasRating")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("books").select(Field.of("rating").exists().as_("hasRating")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("books").select(exists(field("rating")).as("hasRating")).execute().get();

IS_ABSENT

Syntax:

is_absent(value: ANY) -> BOOLEAN

Description:

ReturnsTRUE ifvalue is the absent value, andFALSE otherwise. Absent valuesare values that are missing from the input, such as a missing document field.

Examples:

valueis_absent(value)
0LFALSE
"foo"FALSE
NULLFALSE
ABSENTTRUE

IF_ABSENT

Syntax:

if_absent(value: ANY, replacement: ANY) -> ANY

Description:

Ifvalue is an absent value, evaluates and returnsreplacement. Otherwise returnsvalue.

Examples:

valuereplacementif_absent(value, replacement)
5L0L5L
NULL0LNULL
ABSENT0L0L

IS_ERROR

Syntax:

is_error(try: ANY) -> BOOLEAN

Description:

ReturnsTRUE if an error is thrown during the evaluation oftry. ReturnsFALSE otherwise.

IF_ERROR

Syntax:

if_error(try: ANY, catch: ANY) -> ANY

Description:

If an error is thrown during the evaluation oftry, evaluates and returnsreplacement. Otherwise returns the resolved value oftry.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.