trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
10.49k stars 3.02k forks source link

Add support for PostGIS #24053

Closed umartin closed 2 days ago

umartin commented 2 weeks ago

Description

Add support for geometry type mapping in the PostgreSQL connector.

Additional context and related issues

Issue: #5580 There is an old, inactive PR at #9951

My take is slightly different when it comes to reading PostGIS geometries. The previous attempt rewrote the query and wrapped geometry columns in ST_GeomAsWKB to convert them to a Well Known Binary format. I'm using the native format which is hex encoded EWKB.

Release notes

## PostgreSQL connector 
* Add support for `geometry` type. ({issue}`5580`)
umartin commented 2 weeks ago

I'm having trouble getting the tests to pass. TestPostgreSqlPlugin fails because the geometry type is not injected into PostgreSqlClient. I couldn't figure out how to fixed that.

umartin commented 2 weeks ago

It looks like the TestingConnectorContext used in TestPostgreSqlPlugin doesn't have the geometry type in the type manager. TestingConnectorContext is a final class so I can't extend it. Should I just create a TestingPostgreSqlConnectorContext with an extended type manager?

umartin commented 1 week ago

@ebyhr I think this PR is ready for review. All checks pass. I've also built and tested the trino docker image with postgis manually.

umartin commented 4 days ago

Thank you for your feedback @ebyhr. I've updated the PR with all of your suggestions.