Debugging functions Stay organized with collections Save and categorize content based on your preferences.
GoogleSQL for Bigtable supports the following debugging functions.
Function list
| Name | Summary |
|---|---|
IFERROR | Evaluates a try expression, and if an evaluation error is produced, returns the result of a catch expression. |
ISERROR | Evaluates a try expression, and if an evaluation error is produced, returnsTRUE. |
NULLIFERROR | Evaluates a try expression, and if an evaluation error is produced, returnsNULL. |
IFERROR
IFERROR(try_expression,catch_expression)Description
Evaluatestry_expression.
Whentry_expression is evaluated:
- If the evaluation of
try_expressiondoesn't produce an error, thenIFERRORreturns the result oftry_expressionwithout evaluatingcatch_expression. - If the evaluation of
try_expressionproduces a system error, thenIFERRORproduces that system error. - If the evaluation of
try_expressionproduces an evaluation error, thenIFERRORsuppresses that evaluation error and evaluatescatch_expression.
Ifcatch_expression is evaluated:
- If the evaluation of
catch_expressiondoesn't produce an error, thenIFERRORreturns the result ofcatch_expression. - If the evaluation of
catch_expressionproduces any error, thenIFERRORproduces that error.
Arguments
try_expression: An expression that returns a scalar value.catch_expression: An expression that returns a scalar value.
The results oftry_expression andcatch_expression must share asupertype.
Return Data Type
Thesupertype fortry_expression andcatch_expression.
Example
In the following example, the query successfully evaluatestry_expression.
SELECTIFERROR('a','b')ASresult/*--------+ | result | +--------+ | a | +--------*/In the following example,IFERROR catches an evaluation error in thetry_expression and successfully evaluatescatch_expression.
SELECTIFERROR(ERROR('a'),'b')ASresult/*--------+ | result | +--------+ | b | +--------*/In the following query, the error is handled by the innermostIFERRORoperation,IFERROR(ERROR('a'), 'b').
SELECTIFERROR(IFERROR(ERROR('a'),'b'),'c')ASresult/*--------+ | result | +--------+ | b | +--------*/In the following query, the error is handled by the outermostIFERRORoperation,IFERROR(..., 'c').
SELECTIFERROR(IFERROR(ERROR('a'),ERROR('b')),'c')ASresult/*--------+ | result | +--------+ | c | +--------*/In the following example,IFERROR catches an evaluation error inERROR('a')and then evaluatesERROR('b'). Because there is also an evaluation error inERROR('b'),IFERROR produces an evaluation error forERROR('b').
SELECTIFERROR(ERROR('a'),ERROR('b'))ASresult--ERROR:OUT_OF_RANGE'b'ISERROR
ISERROR(try_expression)Description
Evaluatestry_expression.
- If the evaluation of
try_expressiondoesn't produce an error, thenISERRORreturnsFALSE. - If the evaluation of
try_expressionproduces a system error, thenISERRORproduces that system error. - If the evaluation of
try_expressionproduces an evaluation error, thenISERRORreturnsTRUE.
Arguments
try_expression: An expression that returns a scalar value.
Return Data Type
BOOL
Example
In the following examples,ISERROR successfully evaluatestry_expression.
SELECTISERROR('a')ASis_error/*----------+ | is_error | +----------+ | false | +----------*/SELECTISERROR(2/1)ASis_error/*----------+ | is_error | +----------+ | false | +----------*/In the following examples,ISERROR catches an evaluation error intry_expression.
SELECTISERROR(ERROR('a'))ASis_error/*----------+ | is_error | +----------+ | true | +----------*/SELECTISERROR(2/0)ASis_error/*----------+ | is_error | +----------+ | true | +----------*/NULLIFERROR
NULLIFERROR(try_expression)Description
Evaluatestry_expression.
- If the evaluation of
try_expressiondoesn't produce an error, thenNULLIFERRORreturns the result oftry_expression. If the evaluation of
try_expressionproduces a system error, thenNULLIFERRORproduces that system error.If the evaluation of
try_expressionproduces an evaluation error, thenNULLIFERRORreturnsNULL.
Arguments
try_expression: An expression that returns a scalar value.
Return Data Type
The data type fortry_expression orNULL
Example
In the following example,NULLIFERROR successfully evaluatestry_expression.
SELECTNULLIFERROR('a')ASresult/*--------+ | result | +--------+ | a | +--------*/In the following example,NULLIFERROR catches an evaluation error intry_expression.
SELECTNULLIFERROR(ERROR('a'))ASresult/*--------+ | result | +--------+ | NULL | +--------*/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 2025-12-15 UTC.