Issue
During model deployment, the following error appears "Duplicate Map Key Value <function_name>".
The deployment process stops and prevents the model from being successfully deployed.
Cause
This error typically occurs when the database user connected to the data location schema has visibility over multiple schemas containing the same function definition.
In PostgreSQL environments, this is usually related to an incorrectly configured search_path.
If the user’s search_path includes schemas where said function exists more than once, PostgreSQL detects duplicate function references during deployment, resulting in the duplicate map key error.
Solution
To resolve this issue, ensure that the database user’s search_path is properly configured and limited to the required schemas only.
If you are running on PostgreSQL, verify that the search path is set correctly, typically to:
"$user", public, extensions
You can configure it using the following commands:
ALTER DATABASE <repository_name> SET SEARCH_PATH TO "$user", public, extensions; ALTER ROLE <user> SET SEARCH_PATH TO "$user", <datasource_name>, public, extensions;
After adjusting the search path, retry the deployment.
This ensures that only the appropriate schema definitions are visible, preventing duplicate function detection errors.