Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create table with geometry field #264

Closed
2 tasks done
fnicastri opened this issue Sep 18, 2024 · 12 comments
Closed
2 tasks done

Can't create table with geometry field #264

fnicastri opened this issue Sep 18, 2024 · 12 comments

Comments

@fnicastri
Copy link

What happens?

trying to create a table in a remote Postgis database
wuth create table postgres_db.test_table (id int, location geometry );
duckdb return a generic error:

INTERNAL Error: Unsupported logical type for RemoveAlias
This error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.
For more information, see https://duckdb.org/docs/dev/internal_errors

To Reproduce

load/install the postgres extension
load/install the spatial extension
attach a postgres database

try to create a table with a geometry column:
create table postgres_db.test_table (id int, location geometry );

OS:

mac/linux

PostgreSQL Version:

16 + PostGIS 3.4.2

DuckDB Version:

v1.1.0 fa5c2fe15f (nightly)

DuckDB Client:

cli/python

Full Name:

Francesco Nicastri

Affiliation:

myself

Have you tried this on the latest main branch?

  • 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?

  • I agree
@ken2190
Copy link

ken2190 commented Oct 30, 2024

same problem here

@Hajna
Copy link

Hajna commented Nov 1, 2024

same problem, this is probably expected though

@fnicastri
Copy link
Author

expected, maybe, but it I feel it is not the right behavior.
DuckDb support Postgres, PostGis and have Spatial extension itself,
I think it should be capable to do it.

@francbartoli
Copy link

Same problem with version 1.1.3

@tobwen
Copy link

tobwen commented Nov 14, 2024

Workaround: https://duckdb.org/docs/extensions/postgres#running-sql-queries-in-postgresql

@Youssef-Harby
Copy link

Hi @Maxxen Do you have any plans for this ?

@Maxxen
Copy link
Member

Maxxen commented Jan 13, 2025

@Youssef-Harby yes eventually it would be nice if it was possible to query postgis geometries from duckdb /w spatial, and how that we figured out how to do conversion from geoparquet to spatial geometries doing another cross-extension dependency seems feasible, but I probably won't have time to work on it until sometime after next release.

@fnicastri
Copy link
Author

it would be nice

@Mytherin
Copy link
Contributor

Looked into this a bit - the interaction could be nicer for sure, but it is possible to interact with Postgis from DuckDB currently using some work-arounds:

ATTACH 'dbname=postgres' AS s (TYPE POSTGRES);
LOAD spatial;
CALL postgres_execute(s, 'CREATE TABLE my_points(geom GEOMETRY)');
INSERT INTO s.my_points SELECT ST_Point(1,1);
SELECT ST_GeomFromWKB(unhex(geom)) FROM s.my_points;
┌─────────────────────────────┐
│ st_geomfromwkb(unhex(geom)) │
│          geometry           │
├─────────────────────────────┤
│ POINT (1 1)                 │
└─────────────────────────────┘

@Mytherin
Copy link
Contributor

Made it work using WKB_BLOB in #291

ATTACH 'dbname=postgres' AS postgres_db (TYPE POSTGRES);
CREATE TABLE postgres_db.test_table (id int, location geometry );
INSERT INTO postgres_db.test_table VALUES (42, ST_Point(42, 42));
SELECT * FROM postgres_db.test_table;
┌───────┬───────────────┐
│  id   │   location    │
│ int32 │   wkb_blob    │
├───────┼───────────────┤
│  42POINT (42 42) │
└───────┴───────────────┘

@tjwebb
Copy link

tjwebb commented Feb 14, 2025

are there plans to fix this?

@Mytherin
Copy link
Contributor

This has already been implemented in the latest version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants