22.8. Retrieving Key-Value Pairs from MAP Data (map_entries) #
This stored procedure must be executed inside a duckdb.query() call as Postgres Pro AXE does not support the MAP data type.
Required privileges: Postgres Pro AXE administrator only. For a full list of stored procedures and privileges, refer to Section 12.1.
Execute the following command on the Postgres Pro AXE server:
SELECT * FROM duckdb.query('SELECT map_entries(MAP)') ON CONFLICT DO NOTHING;
Where MAP is the MAP data from which key-value pairs must be retrieved.
You can specify a column with the MAP data type or a MAP literal.
Postgres Pro AXE returns a list of STRUCT values containing the key-value pairs from the MAP data.
Example 22.8. Executing the map_entries Stored Procedure
MAP data in the data column of the map_table table:
id | data
----+-------------------------
1 | {'a': 1, 'b': 2, 'c': 3}
SELECT * FROM duckdb.query('SELECT map_entries(data) FROM map_table') ON CONFLICT DO NOTHING;
[{'key': 'a', 'value': 1}, {'key': 'b', 'value': 2}, {'key': 'c', 'value': 3}]