filterMv
This section contains reference documentation for the filterMv function.
Evaluates each element of a multi-value column against a predicate and returns a filtered multi-value array containing only elements that satisfy the condition.
Signature
filterMv(mvColumn, 'predicate')
Arguments
mvColumn - A multi-value column to filter
predicate - A string containing a predicate expression that uses
vas the placeholder for each element. The predicate is evaluated for each element in the array.
Supported Operators
The predicate supports the following operators:
Comparison:
=,!=,>,>=,<,<=Set membership:
IN,NOT INRange:
BETWEENPattern matching:
REGEXP_LIKELogical:
AND,OR,NOT
Returns
A multi-value array containing only the elements that satisfy the predicate condition.
Usage Examples
Filter integers with comparison operators
Result: Returns elements from intArrayCol that are greater than 10 and less than 50.
Filter strings with REGEXP_LIKE
Result: Returns elements from stringArrayCol that match the regex pattern starting with /api/.
Filter with IN operator
Result: Returns elements from categoryCol that are either 'A', 'B', or 'C'.
Filter with BETWEEN
Result: Returns elements from scoreCol where values are between 70 and 90 (inclusive).
Filter with aggregation in GROUP BY
Result: For each user, returns the filtered array containing only 'click' events.
Notes
The predicate must use
vas the placeholder for the element being evaluated.String values in predicates must be single-quoted or escaped appropriately.
filterMvis useful for element-level filtering without requiringCROSS JOIN UNNEST.The order of elements in the filtered result matches their order in the original array.
Empty or NULL arrays remain unchanged.
Last updated
Was this helpful?

