NUnique / Array Layer
Count unique values in each fixed-length array. Similar to len(set()) in Python or n_distinct() in R. Returns an integer column with the count of distinct values.
Example transformation (arrays of length 3):
arrays | n_unique |
---|---|
[1, 2, 2] | 2 |
[a, a, b] | 2 |
[true, true, false] | 2 |
[1, null, 1] | 1 |
[null, null, null] | 0 |
Common applications:
- Counting distinct categories
- Measuring data variety
- Analyzing value diversity
- Detecting duplicates
- Cardinality analysis
Note: All arrays must have the same fixed length. Null values are ignored in the count. Type-sensitive comparison for uniqueness.
Table
0
0
Table
Select
columnThe fixed-length array column to analyze. All arrays must have same length:
- Numeric arrays: [1, 2, 2]
- String arrays: [red, red, blue]
- Boolean arrays: [true, false, true]
- Date arrays: [2024-01-01, 2024-01-01, 2024-01-02]
AsColumn
nameName for the new column. If not provided, the system generates a unique name. If AsColumn
matches an existing column, the existing column is replaced. The name should follow valid column naming conventions.