# aggThrow (/docs/reference/sql/aggregate-functions/aggthrow)



This page describes the RawTree engine binary used to generate this reference. It does not define Query API support. Descriptions retain upstream ClickHouse terminology. See [SQL interface scope](/docs/reference/clickhouse-compatibility#service-interfaces).

This function can be used for the purpose of testing exception safety. It will throw an exception on creation with the specified probability.

**Syntax**

```sql
aggThrow(throw_prob)
```

**Arguments**

* `throw_prob` — Probability to throw on creation. [`Float64`](/reference/data-types/float)

**Returned value**

Returns an exception: `Code: 503. DB::Exception: Aggregate function aggThrow has thrown exception successfully`.

**Examples**

**Usage example**

```sql title=Query
SELECT number % 2 AS even, aggThrow(number) FROM numbers(10) GROUP BY even;
```

```text title=Response
Received exception:
Code: 503. DB::Exception: Aggregate function aggThrow has thrown exception successfully: While executing AggregatingTransform. (AGGREGATE_FUNCTION_THROW)
```

*Introduced in version 20.1.0.*
