setDiffSymmetric
Description
Returns the symmetric difference of two arrays, producing a new array with elements that exist in either array1
or array2
but not in both.
- Duplicates are discarded when computing the difference.
- Supported element types include
string
,bool
,number
,interval
,timestamp
,regexp
, andenum
.
Syntax
Like many functions in DataPrime, setDiffSymmetric
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: Identify differences between two IP allow lists
Suppose you maintain two separate allow lists of IP addresses. Consider the following input:
{
"ip_addresses_a": ["156.76.87.4", "156.76.12.4", "156.74.1.4"],
"ip_addresses_b": ["156.76.87.4", "156.76.1.4"]
}
By applying setDiffSymmetric
, you can find IPs that exist in one list but not the other.
Output
The result will include a new field diff_ips
showing only the differing elements:
{
"ip_addresses_a": ["156.76.87.4", "156.76.12.4", "156.74.1.4"],
"ip_addresses_b": ["156.76.87.4", "156.76.1.4"],
"diff_ips": ["156.76.12.4", "156.74.1.4", "156.76.1.4"]
}
Theme
Light