---
title: zip_with function
description: Learn the syntax of the zip\_with function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/zip_with
---

# `zip_with` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Merges the arrays in `expr1` and `expr2`, element-wise, into a single array using `func`.

## Syntax

```
zip_with(expr1, expr2, func)
```

## Arguments

* `expr1`: An ARRAY expression.
* `expr2`: An ARRAY expression.
* `func`: A lambda function taking two parameters.

## Returns

An ARRAY of the result of the lambda function.

If one array is shorter, nulls are appended at the end to match the length of the longer array before applying `func`.

## Examples

```sql
> SELECT zip_with(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x));
 [{a, 1}, {b, 2}, {c, 3}]
> SELECT zip_with(array(1, 2), array(3, 4), (x, y) -> x + y);
 [4,6]
> SELECT zip_with(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y));
 [ad , be, cf]
```

## Related functions

* [`array_distinct` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_distinct.md)
* [`array_intersect` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_intersect.md)
* [`array_except` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_except.md)
* [`array_sort` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_sort.md)
* [`array_remove` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_remove.md)
* [`array_union` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_union.md)
