---
title: MAP type
description: The MAP type represents values comprising a set of key-value pairs in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/data-types/map-type
---

# `MAP` type

**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

Represents values comprising a set of key-value pairs.

## Syntax

```
MAP <keyType, valueType>
```

* `keyType`: Any data type other than MAP specifying the keys.
* `valueType`: Any data type specifying the values.

## Limits

The map type supports maps of any cardinality greater or equal to 0.

The keys must be unique and not be NULL.

`MAP` is not a comparable data type.

## Literals

See [`map` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/map.md) for details on how to produce literal map values.

See [\[ \] operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/bracketsign.md) for details on how to retrieve values from a map by key.

## Examples

```sql
> SELECT map('red', 1, 'green', 2);
  {red->1, green->2}

> SELECT typeof(CAST(NULL AS MAP<TIMESTAMP, INT>));
  MAP<TIMESTAMP, INT>

> SELECT map(array(1, 2), map('green', 5));
  {[1, 2]->{green->5}}

> SELECT CAST(map(struct('Hello', 'World'), 'Greeting') AS MAP<STRUCT<w1:string, w2:string>, string>);
  {{Hello, World}->Greeting}

> SELECT m['red'] FROM VALUES(map('red', 1, 'green', 2)) AS T(m);
  1

> SELECT map('red', 1) = map('red', 1);
  Error: EqualTo does not support ordering on type map<string,int>
```

## Related

* [\[ \] operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/bracketsign.md)
* [`ARRAY` type](https://docs.databricks.com/aws/en/sql/language-manual/data-types/array-type.md)
* [`STRUCT` type](https://docs.databricks.com/aws/en/sql/language-manual/data-types/struct-type.md)
* [`map` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/map.md)
* [`cast` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/cast.md)
