22.7. Checking a MAP Value (map_contains_value) #

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

Where:

  • MAP: The MAP data where the search must be performed.

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

  • value: The value that must be searched.

Postgres Pro AXE returns true if the MAP data contains the value and false otherwise.

Example 22.7. Executing the map_contains_value Stored Procedure

MAP data in the data column of the map_table table:

 id |          data
----+-------------------------
  1 | {'a': 1, 'b': 2}

Checking MAP data for an existing value:

  SELECT * FROM duckdb.query('SELECT map_contains_value(data, 2) FROM map_table') ON CONFLICT DO NOTHING;
  true

Checking MAP data for a missing value:

  SELECT * FROM duckdb.query('SELECT map_contains_value(data, 5) FROM map_table') ON CONFLICT DO NOTHING;
  false