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
, andenum
.
Syntax
Like many functions in DataPrime, setEqualsTo
supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
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:
{
"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.
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
}
Theme
Light