---
title: assert_true function
description: Learn the syntax of the assert\_true function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/assert_true
---

# `assert_true` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) 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](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 14.2 and above

The returned error condition is [USER\_RAISED\_EXCEPTION](https://docs.databricks.com/aws/en/error-messages/error-classes.md#user_raised_exception) and the `SQLSTATE` is `P0001`.

See [Handling error conditions](https://docs.databricks.com/aws/en/error-messages/index.md#handling-error-conditions) for details on handling error conditions.

## Common error conditions

* [USER\_RAISED\_EXCEPTION](https://docs.databricks.com/aws/en/error-messages/error-classes.md#user_raised_exception)

## Examples

```sql
> SELECT assert_true(0 < 1);
 NULL

> SELECT assert_true(0 > 1);
  Error: USER_RAISED_EXCEPTION

> SELECT assert_true(1 = 2, 'One is not two!');
  Error: USER_RAISED_EXCEPTION
```

## Related

* [Handling error conditions](https://docs.databricks.com/aws/en/error-messages/index.md#handling-error-conditions)
* [`raise_error` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/raise_error.md)
