# `isSubset`

## Description

Returns `true` if `array1` is a subset of `array2`, or `false` otherwise.

- When comparing `array1` and `array2`, 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, `isSubset` 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
isSubset(array1: array<T>, array2: array<T>): bool
```

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

## Arguments

| Name   | Type  | Required | Description                                                      |
| ------ | ----- | -------- | ---------------------------------------------------------------- |
| array1 | array | **true** | The array to test as a subset                                    |
| array2 | array | **true** | The array to test against, must contain all elements of `array1` |

## Example

**Use case: Verify if started jobs are part of all jobs**

Suppose you want to confirm that a list of started jobs is fully contained within the list of all jobs. Consider the following input:

```json
{
    "all_jobs": ["Chris", "Quinn", "Flo", "Meta", "Neo"],
    "started_jobs": ["Chris", "Quinn"]
}
```

By applying `isSubset`, you can check if every element of `started_jobs` exists within `all_jobs`.

### Example query

```dataprime
create is_subset from isSubset(started_jobs, all_jobs)
```

```dataprime
create is_subset from started_jobs.isSubset(all_jobs)
```

### Example output

The result will include a new field `is_subset` indicating whether the subset condition is satisfied:

```json
{
    "all_jobs": ["Chris", "Quinn", "Flo", "Meta", "Neo"],
    "started_jobs": ["Chris", "Quinn"],
    "is_subset": true
}
```
