assert_true function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Returns an error if expr is not true.

Syntax

assert_true(condition [, message])

Arguments

  • condition: A BOOLEAN expression.

  • message: An optional STRING expression with a message. The default is '<condition>' is not true!.

Returns

An untyped NULL if no error is returned.

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 14.2 and later

The returned error class is USER_RAISED_EXCEPTION and the SQLSTATE is P0001.

See Handling error conditions for details on handling error conditions.

Examples

> SELECT assert_true(0 < 1);
 NULL

> SELECT assert_true(0 > 1);
 [USER_RAISED_EXCEPTION] '0 > 1' is not true! SQLSTATE: P0001

> SELECT assert_true(1 = 2, 'One is not two!');
 [USER_RAISED_EXCEPTION] One is not two! SQLSTATE: P0001