> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# array_repeat

> array_repeat returns an array containing a given element repeated a specified number of times.

`array_repeat` returns an array containing a given element repeated a specified number of times.

## Syntax

```Haskell theme={null}
array_repeat(element, count)
```

## Parameters

* `element`: The element to be repeated can be any data type supported by the database.

* `count`: The number of repetitions, of type INT.

## Return value

The data type of the return value is the ARRAY type of element.

## Usage notes

* When count is less than 1, an empty array is returned.
* When the element parameter is NULL, the result is an array consisting of count NULLs.
* When the count parameter is NULL, the result is NULL.

## Examples

Example 1:

```sql theme={null}
select array_repeat(1,5) as res;
```

```sql theme={null}
+-------------+
| res         |
+-------------+
| [1,1,1,1,1] |
+-------------+
```

Example 2:

```sql theme={null}
select  array_repeat([1,2],3) as res;
```

```sql theme={null}
+---------------------+
| res                 |
+---------------------+
| [[1,2],[1,2],[1,2]] |
+---------------------+
```

Example 3:

```sql theme={null}
select array_repeat(1,-1) as res;
```

```sql theme={null}
+------+
| res  |
+------+
| []   |
+------+
```

Example 4:

```sql theme={null}
select  array_repeat(null,3) as res;
```

```sql theme={null}
+------+
| res  |
+------+
| NULL |
+------+
```

Example 5:

```sql theme={null}
CREATE TABLE IF NOT EXISTS test (COLA INT, COLB INT) PROPERTIES ("replication_num"="1");
INSERT INTO test (COLA, COLB) VALUES (1, 3), (NULL, 3), (2, NULL);
select array_repeat(COLA,COLB) from test;
```

```sql theme={null}
+--------------------------+
| array_repeat(COLA, COLB) |
+--------------------------+
| [1,1,1]                  |
| [null,null,null]         |
| NULL                     |
+--------------------------+
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.