FDW column name not found
SQLSTATE HV005 is raised when a foreign data wrapper cannot find a column name in the descriptor returned by the remote data source — the local foreign table definition references a column that does not exist in the remote table.
- 1The foreign table definition includes a column name that does not exist in the remote table or file
- 2Remote table schema changed and a column was renamed or dropped
Foreign table referencing a non-existent remote column.
-- Foreign table defines column "email" but remote table has "email_address": SELECT email FROM remote_users;
expected output
ERROR: column "email" does not exist on foreign server
Fix 1
Use the column_name option to map local to remote column names
WHEN When the local and remote column names differ.
ALTER FOREIGN TABLE remote_users ALTER COLUMN email OPTIONS (SET column_name 'email_address');
Why this works
The column_name option maps the local foreign table column name to the actual column name on the remote server.
Fix 2
Recreate the foreign table with the correct column names
WHEN When the remote schema has changed.
Why this works
Drop and recreate the foreign table using IMPORT FOREIGN SCHEMA or manually with the current remote column names.
Class HV — Foreign Data Wrapper Error
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev