22.9. Retrieving Keys from MAP Data (map_keys) #

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_keys(MAP)') ON CONFLICT DO NOTHING;

Where MAP is the MAP data from which keys must be retrieved.

You can specify a column with the MAP data type or a MAP literal.

Postgres Pro AXE returns a list of keys from the MAP data.

Example 22.9. Executing the map_keys 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_keys(data) FROM map_table') ON CONFLICT DO NOTHING;
  [a, b, c]