pgsql-ogr-fdw icon indicating copy to clipboard operation
pgsql-ogr-fdw copied to clipboard

ogr generating duplicate column names when column names truncated because of 63 character limit

Open robe2 opened this issue 9 months ago • 1 comments

So it's odd this is the first time I'm running into it. But I have a CSV file that has headers as long as 84 characters, and when they are shrunk to the 63 character limit allowed for identifiers -- as noted on this page - https://www.postgresql.org/docs/current/limits.html some of the columns get truncated to the same name and thus can't be loaded. It yields the same error as what you get with #252 but I assume this is fixable.

CREATE SERVER svr_csv_test
    FOREIGN DATA WRAPPER ogr_fdw
    OPTIONS (datasource '/fdw_data/csvs', format 'CSV');

IMPORT FOREIGN SCHEMA ogr_all LIMIT TO (test) FROM SERVER svr_csv_test INTO staging;

Get error if I have the attached file in the folder

test.csv

NOTICE:  Number of tables to be created 1
ERROR:  column "this_column_name_is_very_very_long_aaaaaaaaaaaaaaaaaaaaaaaaaaaa" specified more than once
CONTEXT:  importing foreign table "test" 

robe2 avatar Apr 08 '25 22:04 robe2