# `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/dataprime/language-reference/functions-reference/index.md), **function** and **method** notation. These interchangeable forms allow flexibility in how you structure expressions.

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

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

## Arguments

| Name   | Type  | Required | Description                 |
| ------ | ----- | -------- | --------------------------- |
| array1 | array | **true** | The first array to compare  |
| array2 | array | **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:

```json
{
    "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

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

```dataprime
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:

```json
{
    "array_1": ["val1", "val1", "val2", "val2", "val3"],
    "array_2": ["val1", "val2", "val3", "val3", "val3"],
    "arrays_equal": true
}
```
