22.6. Checking a MAP Key-Value Pair (map_contains_entry) #
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_entry(MAP, key, 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.
key: The key that must be searched.value: The value that must be searched.
Postgres Pro AXE returns true if the MAP data contains the key-value pair and false otherwise.
Example 22.6. Executing the map_contains_entry 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 key-value pair:
SELECT * FROM duckdb.query('SELECT map_contains_entry(data, ''a'', 1) FROM map_table') ON CONFLICT DO NOTHING;
true
Checking MAP data for a missing key-value pair:
SELECT * FROM duckdb.query('SELECT map_contains_entry(data, ''a'', 5) FROM map_table') ON CONFLICT DO NOTHING;
false