> For the complete documentation index, see [llms.txt](https://docs.pinot.apache.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pinot.apache.org/functions/array/filtermv.md).

# filterMv

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 `v` as 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 IN`
* Range: `BETWEEN`
* Pattern matching: `REGEXP_LIKE`
* Logical: `AND`, `OR`, `NOT`

## Returns

A multi-value array containing only the elements that satisfy the predicate condition.

## Usage Examples

### Filter integers with comparison operators

```sql
SELECT filterMv(intArrayCol, 'v > 10 AND v < 50') AS filtered
FROM myTable
LIMIT 10
```

Result: Returns elements from `intArrayCol` that are greater than 10 and less than 50.

### Filter strings with REGEXP\_LIKE

```sql
SELECT filterMv(stringArrayCol, 'REGEXP_LIKE(v, ''^/api/.*'')')
FROM myTable
LIMIT 10
```

Result: Returns elements from `stringArrayCol` that match the regex pattern starting with `/api/`.

### Filter with IN operator

```sql
SELECT filterMv(categoryCol, 'v IN (''A'', ''B'', ''C'')')
FROM myTable
LIMIT 10
```

Result: Returns elements from `categoryCol` that are either 'A', 'B', or 'C'.

### Filter with BETWEEN

```sql
SELECT filterMv(scoreCol, 'v BETWEEN 70 AND 90')
FROM myTable
LIMIT 10
```

Result: Returns elements from `scoreCol` where values are between 70 and 90 (inclusive).

### Filter with aggregation in GROUP BY

```sql
SELECT
  userId,
  COUNT(*) as count,
  filterMv(eventTypes, 'v = ''click''') as clickEvents
FROM events
GROUP BY userId
LIMIT 10
```

Result: For each user, returns the filtered array containing only 'click' events.

## Notes

* The predicate must use `v` as the placeholder for the element being evaluated.
* String values in predicates must be single-quoted or escaped appropriately.
* `filterMv` is useful for element-level filtering without requiring `CROSS JOIN UNNEST`.
* The order of elements in the filtered result matches their order in the original array.
* Empty or NULL arrays remain unchanged.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.pinot.apache.org/functions/array/filtermv.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
