Contains / List Layer
Check if variable-length lists contain a specific value. Similar to Python's in operator or JavaScript's includes(). Returns a boolean column indicating whether each list contains the specified item. Supports lists of different lengths.
Example transformation:
lists | contains_3 |
---|---|
[1, 3, 5, 7] | true |
[2, 4] | false |
[3] | true |
[null, 3, null, 4] | true |
[] | false |
Common applications:
- Checking user permissions in role lists
- Detecting keywords in variable-length text tokens
- Validating product categories in catalog entries
- Finding specific events in activity logs
- Testing feature presence in dynamic feature sets
- Membership verification in varying-size groups
Note: Lists can have any length, including empty. Type-sensitive comparison. Returns false for empty lists and null if list contains only nulls. Particularly useful for searching through collections of varying sizes, like log entries or user attributes.
Select
columnThe variable-length list column to search. Supports various types:
- Numeric lists: [1, 2, 3, 4, 5]
- String lists: [red, blue, green, yellow]
- Boolean lists: [true, false]
- Date lists: [2024-01-01, 2024-02-01] Lists can have different lengths. Mixed types not supported.
Item
stringThe value to search for (Item
). Must match list element type. Examples:
- Numeric: 42 (search in [1, 42, 3, 4])
- String: blue (search in [red, green, blue])
- Boolean: true (search in [false, true])
- Date: 2024-01-31 (search in [2024-01-15, 2024-01-31])
- Time: 15:30:00 (search in [09:00:00, 15:30:00, 18:00:00])
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.