Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Farray%2Fsetequalsto.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Farray%2Fsetequalsto.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `setEqualsTo`

## Description

Returns `true` if `array1` and `array2` contain the same unique elements, or `false` otherwise.

* When comparing arrays, duplicates are discarded. This means two arrays of different lengths but with the same unique elements are considered equal.
* Supported element types include `string`, `bool`, `number`, `interval`, `timestamp`, `regexp`, and `enum`.

## Syntax

Like many functions in DataPrime, `setEqualsTo` supports<!-- --> [two notations](https://coralogix.com/docs/docs/dataprime/language-reference/functions-reference/.md),<!-- --> **function** and **method**. These interchangeable forms allow flexibility in how you structure expressions.

* Function notation
* Method notation

```
setEqualsTo(array1: array<T>, array2: array<T>): bool
```

```
(array1: array<T>).setEqualsTo(array2: array<T>): bool
```

## Arguments

| Name     | Type       | Required | Description                 |
| -------- | ---------- | -------- | --------------------------- |
| `array1` | `array<T>` | **true** | The first array to compare  |
| `array2` | `array<T>` | **true** | The second array to compare |

## Example

**Use case: Compare arrays for unique element equality**

Suppose you have two arrays that may contain duplicate elements. Consider the following input:

```
{

    "array_1": ["val1", "val1", "val2", "val2", "val3"],

    "array_2": ["val1", "val2", "val3", "val3", "val3"]

}
```

By applying `setEqualsTo`, you can determine if both arrays contain the same set of unique values, regardless of duplicates.

### Example query

* Function notation
* Method notation

```
create arrays_equal from setEqualsTo(array_1, array_2)
```

```
create arrays_equal from array_1.setEqualsTo(array_2)
```

### Example output

The result will include a new field `arrays_equal` indicating whether the sets are equal:

```
{

    "array_1": ["val1", "val1", "val2", "val2", "val3"],

    "array_2": ["val1", "val2", "val3", "val3", "val3"],

    "arrays_equal": true

}
```
