CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 16:54:57 GMT
content-type: text/html; charset=utf-8
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
server: cloudflare
x-origin-cache: HIT
last-modified: Sun, 12 Oct 2025 15:31:11 GMT
access-control-allow-origin: *
expires: Sun, 12 Oct 2025 17:04:57 GMT
cache-control: max-age=600
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=FslL%2FAIAi%2B9%2FbIHbS2JFiEbUTg3sM0UwslfIzmVMx1w2bFUomntVznA1ybdRynGOkfzSpPdP0vbNgfq3pODPbw%2B9tx%2BSEqgYlw%3D%3D"}]}
x-proxy-cache: MISS
x-github-request-id: 8B02:284228:114D0A:14C83B:68EBDD60
age: 0
via: 1.1 varnish
x-served-by: cache-bom-vanm7210042-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1760288097.995232,VS0,VE290
vary: Accept-Encoding
x-fastly-request-id: 2e9708b9ea4ad8c35983eacb88a86df04cb6086c
cf-cache-status: DYNAMIC
content-encoding: gzip
cf-ray: 98d81f3e0c60b277-BLR
alt-svc: h3=":443"; ma=86400
Map Functions – DuckDB
Search Shortcut cmd + k | ctrl + k
- Installation
- Documentation
- Getting Started
- Connect
- Data Import
- Overview
- Data Sources
- CSV Files
- JSON Files
- Overview
- Creating JSON
- Loading JSON
- Writing JSON
- JSON Type
- JSON Functions
- Format Settings
- Installing and Loading
- SQL to / from JSON
- Caveats
- Multiple Files
- Parquet Files
- Partitioning
- Appender
- INSERT Statements
- Client APIs
- Overview
- Tertiary Clients
- ADBC
- C
- Overview
- Startup
- Configuration
- Query
- Data Chunks
- Vectors
- Values
- Types
- Prepared Statements
- Appender
- Table Functions
- Replacement Scans
- API Reference
- C++
- CLI
- Overview
- Arguments
- Dot Commands
- Output Formats
- Editing
- Safe Mode
- Autocomplete
- Syntax Highlighting
- Known Issues
- Dart
- Go
- Java (JDBC)
- Julia
- Node.js (Deprecated)
- Node.js (Neo)
- ODBC
- PHP
- Python
- Overview
- Data Ingestion
- Conversion between DuckDB and Python
- DB API
- Relational API
- Function API
- Types API
- Expression API
- Spark API
- API Reference
- Known Python Issues
- R
- Rust
- Swift
- Wasm
- SQL
- Introduction
- Statements
- Overview
- ANALYZE
- ALTER DATABASE
- ALTER TABLE
- ALTER VIEW
- ATTACH and DETACH
- CALL
- CHECKPOINT
- COMMENT ON
- COPY
- CREATE INDEX
- CREATE MACRO
- CREATE SCHEMA
- CREATE SECRET
- CREATE SEQUENCE
- CREATE TABLE
- CREATE VIEW
- CREATE TYPE
- DELETE
- DESCRIBE
- DROP
- EXPORT and IMPORT DATABASE
- INSERT
- LOAD / INSTALL
- MERGE INTO
- PIVOT
- Profiling
- SELECT
- SET / RESET
- SET VARIABLE
- SUMMARIZE
- Transaction Management
- UNPIVOT
- UPDATE
- USE
- VACUUM
- Query Syntax
- SELECT
- FROM and JOIN
- WHERE
- GROUP BY
- GROUPING SETS
- HAVING
- ORDER BY
- LIMIT and OFFSET
- SAMPLE
- Unnesting
- WITH
- WINDOW
- QUALIFY
- VALUES
- FILTER
- Set Operations
- Prepared Statements
- Data Types
- Overview
- Array
- Bitstring
- Blob
- Boolean
- Date
- Enum
- Interval
- List
- Literal Types
- Map
- NULL Values
- Numeric
- Struct
- Text
- Time
- Timestamp
- Time Zones
- Union
- Typecasting
- Expressions
- Overview
- CASE Expression
- Casting
- Collations
- Comparisons
- IN Operator
- Logical Operators
- Star Expression
- Subqueries
- TRY
- Functions
- Overview
- Aggregate Functions
- Array Functions
- Bitstring Functions
- Blob Functions
- Date Format Functions
- Date Functions
- Date Part Functions
- Enum Functions
- Interval Functions
- Lambda Functions
- List Functions
- Map Functions
- Nested Functions
- Numeric Functions
- Pattern Matching
- Regular Expressions
- Struct Functions
- Text Functions
- Time Functions
- Timestamp Functions
- Timestamp with Time Zone Functions
- Union Functions
- Utility Functions
- Window Functions
- Constraints
- Indexes
- Meta Queries
- DuckDB's SQL Dialect
- Overview
- Indexing
- Friendly SQL
- Keywords and Identifiers
- Order Preservation
- PostgreSQL Compatibility
- SQL Quirks
- Samples
- Configuration
- Extensions
- Overview
- Installing Extensions
- Advanced Installation Methods
- Distributing Extensions
- Versioning of Extensions
- Troubleshooting of Extensions
- Core Extensions
- Overview
- AutoComplete
- Avro
- AWS
- Azure
- Delta
- DuckLake
- Encodings
- Excel
- Full Text Search
- httpfs (HTTP and S3)
- Iceberg
- Overview
- Iceberg REST Catalogs
- Amazon S3 Tables
- Amazon SageMaker Lakehouse (AWS Glue)
- Troubleshooting
- ICU
- inet
- jemalloc
- MySQL
- PostgreSQL
- Spatial
- SQLite
- TPC-DS
- TPC-H
- UI
- VSS
- Guides
- Overview
- Data Viewers
- Database Integration
- File Formats
- Overview
- CSV Import
- CSV Export
- Directly Reading Files
- Excel Import
- Excel Export
- JSON Import
- JSON Export
- Parquet Import
- Parquet Export
- Querying Parquet Files
- File Access with the file: Protocol
- Network and Cloud Storage
- Overview
- HTTP Parquet Import
- S3 Parquet Import
- S3 Parquet Export
- S3 Iceberg Import
- S3 Express One
- GCS Import
- Cloudflare R2 Import
- DuckDB over HTTPS / S3
- Fastly Object Storage Import
- Meta Queries
- Describe Table
- EXPLAIN: Inspect Query Plans
- EXPLAIN ANALYZE: Profile Queries
- List Tables
- Summarize
- DuckDB Environment
- ODBC
- Performance
- Overview
- Environment
- Import
- Schema
- Indexing
- Join Operations
- File Formats
- How to Tune Workloads
- My Workload Is Slow
- Benchmarks
- Working with Huge Databases
- Python
- Installation
- Executing SQL
- Jupyter Notebooks
- marimo Notebooks
- SQL on Pandas
- Import from Pandas
- Export to Pandas
- Import from Numpy
- Export to Numpy
- SQL on Arrow
- Import from Arrow
- Export to Arrow
- Relational API on Pandas
- Multiple Python Threads
- Integration with Ibis
- Integration with Polars
- Using fsspec Filesystems
- SQL Editors
- SQL Features
- Snippets
- Creating Synthetic Data
- Dutch Railway Datasets
- Sharing Macros
- Analyzing a Git Repository
- Importing Duckbox Tables
- Copying an In-Memory Database to a File
- Troubleshooting
- Glossary of Terms
- Browsing Offline
- Operations Manual
- Overview
- DuckDB's Footprint
- Logging
- Securing DuckDB
- Non-Deterministic Behavior
- Limits
- DuckDB Docker Container
- Development
- DuckDB Repositories
- Profiling
- Building DuckDB
- Overview
- Build Configuration
- Building Extensions
- Android
- Linux
- macOS
- Raspberry Pi
- Windows
- Python
- R
- Troubleshooting
- Unofficial and Unsupported Platforms
- Benchmark Suite
- Testing
- Internals
- Sitemap
- Live Demo
Documentation
/ SQL
/ Functions
Map Functions
Name | Description |
---|---|
cardinality(map) |
Return the size of the map (or the number of entries in the map). |
element_at(map, key) |
Return the value for a given key as a list, or an empty list if the key is not contained in the map. The type of the key provided in the second parameter must match the type of the map's keys; else, an error is thrown. |
map_concat(maps...) |
Returns a map created from merging the input maps . On key collision the value is taken from the last map with that key. |
map_contains(map, key) |
Checks if a map contains a given key. |
map_contains_entry(map, key, value) |
Check if a map contains a given key-value pair. |
map_contains_value(map, value) |
Checks if a map contains a given value. |
map_entries(map) |
Return a list of struct(k, v) for each key-value pair in the map. |
map_extract(map, key) |
Return the value for a given key as a list, or an empty list if the key is not contained in the map. The type of the key provided in the second parameter must match the type of the map's keys; else, an error is thrown. |
map_extract_value(map, key) |
Returns the value for a given key or NULL if the key is not contained in the map. The type of the key provided in the second parameter must match the type of the map's keys; else, an error is thrown. |
map_from_entries(STRUCT(k, v)[]) |
Returns a map created from the entries of the array. |
map_keys(map) |
Return a list of all keys in the map. |
map_values(map) |
Return a list of all values in the map. |
map() |
Returns an empty map. |
map[entry] |
Returns the value for a given key or NULL if the key is not contained in the map. The type of the key provided in the second parameter must match the type of the map's keys; else, an error is thrown. |
cardinality(map)
Description | Return the size of the map (or the number of entries in the map). |
Example | cardinality(map([4, 2], ['a', 'b'])) |
Result | 2 |
element_at(map, key)
Description | Return the value for a given key as a list, or an empty list if the key is not contained in the map. The type of the key provided in the second parameter must match the type of the map's keys; else, an error is thrown. |
Example | element_at(map([100, 5], [42, 43]), 100) |
Result | [42] |
Aliases | map_extract(map, key) |
map_concat(maps...)
Description | Returns a map created from merging the input maps . On key collision the value is taken from the last map with that key. |
Example | map_concat(MAP {'key1': 10, 'key2': 20}, MAP {'key3': 30}, MAP {'key2': 5}) |
Result | {key1=10, key2=5, key3=30} |
map_contains(map, key)
Description | Checks if a map contains a given key. |
Example | map_contains(MAP {'key1': 10, 'key2': 20, 'key3': 30}, 'key2') |
Result | true |
map_contains_entry(map, key, value)
Description | Check if a map contains a given key-value pair. |
Example | map_contains_entry(MAP {'key1': 10, 'key2': 20, 'key3': 30}, 'key2', 20) |
Result | true |
map_contains_value(map, value)
Description | Checks if a map contains a given value. |
Example | map_contains_value(MAP {'key1': 10, 'key2': 20, 'key3': 30}, 20) |
Result | true |
map_entries(map)
Description | Return a list of struct(k, v) for each key-value pair in the map. |
Example | map_entries(map([100, 5], [42, 43])) |
Result | [{'key': 100, 'value': 42}, {'key': 5, 'value': 43}] |
map_extract(map, key)
Description | Return the value for a given key as a list, or NULL if the key is not contained in the map. The type of the key provided in the second parameter must match the type of the map's keys else an error is returned. |
Example | map_extract(map([100, 5], [42, 43]), 100) |
Result | [42] |
Aliases | element_at(map, key) |
map_extract_value(map, key)
Description | Returns the value for a given key or NULL if the key is not contained in the map. The type of the key provided in the second parameter must match the type of the map's keys; else, an error is thrown. |
Example | map_extract_value(map([100, 5], [42, 43]), 100); |
Result | 42 |
Aliases | map[key] |
map_from_entries(STRUCT(k, v)[])
Description | Returns a map created from the entries of the array. |
Example | map_from_entries([{k: 5, v: 'val1'}, {k: 3, v: 'val2'}]) |
Result | {5=val1, 3=val2} |
map_keys(map)
Description | Return a list of all keys in the map. |
Example | map_keys(map([100, 5], [42,43])) |
Result | [100, 5] |
map_values(map)
Description | Return a list of all values in the map. |
Example | map_values(map([100, 5], [42, 43])) |
Result | [42, 43] |
map()
Description | Returns an empty map. |
Example | map() |
Result | {} |
map[entry]
Description | Returns the value for a given key or NULL if the key is not contained in the map. The type of the key provided in the second parameter must match the type of the map's keys; else, an error is thrown. |
Example | map([100, 5], ['a', 'b'])[100] |
Result | a |
Aliases | map_extract_value(map, key) |
About this page
© 2025 DuckDB Foundation, Amsterdam NL