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

# `transform` 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

Transforms elements in an array in `expr` using the function `func`.

## Syntax

```
transform(expr, func)
```

## Arguments

* `expr`: An ARRAY expression.
* `func`: A lambda function.

## Returns

An ARRAY of the type of the lambda function's result.

The lambda function must have 1 or 2 parameters.
The first parameter represents the element, the optional second parameter represents the index of the element.

The lambda function produces a new value for each element in the array.

## Examples

```sql
> SELECT transform(array(1, 2, 3), x -> x + 1);
 [2,3,4]
> SELECT transform(array(1, 2, 3), (x, i) -> x + i);
 [1,3,5]
```

## Related functions

* [`transform_keys` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/transform_keys.md)
* [`transform_values` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/transform_values.md)
