Stay organized with collections Save and categorize content based on your preferences.
GoogleSQL for BigQuery supports the following debugging statements.
ASSERT
ASSERT expression [AS description]
Description
Evaluates expression
.
If expression
evaluates to TRUE
, the statement returns successfully without any result.
If expression
evaluates to FALSE
or NULL
, the statement generates an error. If AS description
is present, description
will appear in the error message.
expression
must evaluate to a BOOL
.
description
must be a STRING
literal.
An ASSERT
statement is billed in the same way as the query SELECT expression
, except that the result of an ASSERT
statement is never cached.
Examples
The following examples assert that the data source contains more than a specific number of rows.
-- This query succeeds and no error is produced.
ASSERT (
(SELECT COUNT(*) > 5 FROM UNNEST([1, 2, 3, 4, 5, 6]))
) AS 'Table must contain more than 5 rows.';
-- Error: Table must contain more than 10 rows.
ASSERT (
(SELECT COUNT(*) > 10 FROM UNNEST([1, 2, 3, 4, 5, 6]))
) AS 'Table must contain more than 10 rows.';
The following examples assert that the data source contains a particular value.
-- This query succeeds and no error is produced.
ASSERT
EXISTS(
(SELECT X FROM UNNEST([7877, 7879, 7883, 7901, 7907]) AS X WHERE X = 7907))
AS 'Column X must contain the value 7907.';
-- Error: Column X must contain the value 7919.
ASSERT
EXISTS(
(SELECT X FROM UNNEST([7877, 7879, 7883, 7901, 7907]) AS X WHERE X = 7919))
AS 'Column X must contain the value 7919';
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["`ASSERT` statements in GoogleSQL for BigQuery check if a given expression is true; if it is, the statement completes without issue, otherwise, it generates an error."],["The `ASSERT` statement includes an optional `AS description` clause, which allows for a custom message to be displayed in the error if the assertion fails."],["The expression within an `ASSERT` statement must evaluate to a boolean (`BOOL`) value, and the optional description must be a string literal (`STRING`)."],["`ASSERT` statements are used to validate data, ensuring that it meets specific criteria, such as containing a certain number of rows or specific values."],["Billing for an `ASSERT` statement is equivalent to the `SELECT expression` query, but the result is never cached."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4