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

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

Creates a map with a pair of the `keys` and `values` arrays.

## Syntax

```
map_from_arrays(keys, values)
```

## Arguments

* `keys`: An ARRAY expression without duplicates or NULL.
* `values`: An ARRAY expression of the same cardinality as `keys`

## Returns

A MAP where keys are of the element type of `keys` and values are of the element type of `values`.

Databricks raises [DUPLICATED\_MAP\_KEY](https://docs.databricks.com/aws/en/error-messages/error-classes.md#duplicated_map_key) if `keys` contains duplicates.

## Common error conditions

* [DUPLICATED\_MAP\_KEY](https://docs.databricks.com/aws/en/error-messages/error-classes.md#duplicated_map_key)

## Examples

```sql
> SELECT map_from_arrays(array(1.0, 3.0), array('2', '4'));
 {1.0 -> 2, 3.0 -> 4}

> SELECT map_from_arrays(array(1, 1), array('a', 'b'));
  Error: DUPLICATED_MAP_KEY
```

## Related functions

* [`map` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/map.md)
* [`map_concat` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/map_concat.md)
* [`map_entries` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/map_entries.md)
* [`map_filter` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/map_filter.md)
* [`map_from_entries` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/map_from_entries.md)
* [`map_keys` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/map_keys.md)
* [`map_values` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/map_values.md)
* [`map_zip_with` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/map_zip_with.md)
