22.4. Concatenating MAP Values (map_concat) #
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_concat(MAP[, MAP ...])') ON CONFLICT DO NOTHING;
Where MAP are comma-separated MAP values that must be concatenated.
You can specify columns with the MAP data type or MAP literals.
Postgres Pro AXE concatenates the specified MAP values into a single MAP value. If multiple values contain the same key, the last value takes precedence.
Example 22.4. Executing the map_concat Stored Procedure
MAP data in the data1 and data2 columns of the map_table table:
id | data1 | data2
----+--------------------+--------------------
1 | {'a': 1} | {'b': 2}
2 | {'a': 1, 'b': 2} | {'b': 3, 'c': 4}
Concatenating two MAP values with distinct keys:
SELECT * FROM duckdb.query('SELECT map_concat(data1, data2) FROM map_table WHERE id = 1') ON CONFLICT DO NOTHING;
{a=1, b=2}
Concatenating two MAP values that contain the same key:
SELECT * FROM duckdb.query('SELECT map_concat(data1, data2) FROM map_table WHERE id = 2') ON CONFLICT DO NOTHING;
{a=1, b=3, c=4}