Array FILTER/TRANSFORM lambda using index
Snowflake supports higher order functions like FILTER or TRANSFORM. A lambda expression that defines the filter condition on each array element. The lambda expression must have only one argument specified in the following syntax: <arg> [ <datatype> ] -> <expr> This type of functions may be also known as array_filter/list_filter, array_map, array_transform, apply, etc. Example: SELECT FILTER([10,20,30,40], x -> x > 20); -- [30, 40] My scenario requires to operate on element's index of the array, like choosing every second element. Pseudocode below: SELECT FILTER([10,20,30,40], (x, i) -> i % 2 =
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.