postgres_scanner icon indicating copy to clipboard operation
postgres_scanner copied to clipboard

Can't create a Postgis table from a geojson file

Open ericemc3 opened this issue 10 months ago • 0 comments

What happens?

I want to create a spatial table into my Postgis Database from a geojson file, using duckdb-postgres.

To Reproduce

CREATE OR REPLACE TABLE postgres_db.provincie_2025 AS
FROM st_read('https://cartomap.github.io/nl/wgs84/provincie_2025.geojson');

This fails:

SQL Error: Invalid Error: Failed to copy data: ERREUR:  Invalid endian flag value encountered.
CONTEXT:  COPY provincie_2025, ligne 1, colonne geom

However, this will work, but is much more complex:

CREATE OR REPLACE TABLE postgres_db.provincie_2025 AS
FROM st_read('https://cartomap.github.io/nl/wgs84/provincie_2025.geojson')
SELECT * replace(st_astext(geom) AS geom);

CALL postgres_execute('postgres_db', 
"alter table provincie_2025 add column geom_4326 GEOMETRY('MULTIPOLYGON', '4326');
update provincie_2025 set geom_4326 = ST_GeomFromText(geom);
alter table provincie_2025 drop column geom");

OS:

Win11

PostgreSQL Version:

16.0

DuckDB Version:

1.2.2

DuckDB Client:

Java

Full Name:

eric mauviere

Affiliation:

icem7

Have you tried this on the latest main branch?

  • [x] I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • [x] I agree

ericemc3 avatar Apr 25 '25 15:04 ericemc3