Skip to content

[Feature][PostgreSQL-jdbc] Supports GEOMETRY data type for PostgreSQL #4652

@ic4y

Description

@ic4y

Search before asking

  • I had searched in the feature and found no similar feature requirement.

Description

Currently, the Pg source connector does not support the GEOMETRY data type. We can convert the GEOMETRY data type to the String data type in Zeta to support the reading of GEOMETRY data types, like pg(GEOMETRY) -> zeta(String).

You may need to modify the following files in the JDBC connector:
src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/psql/PostgresTypeMapper.java
src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/psql/PostgresJdbcRowConverter.java

When testing, note that Pg needs to install the PostGIS plugin:

apt-get install postgis postgresql-12-postgis-3
CREATE EXTENSION IF NOT EXISTS postgis;

Create a table and insert data:

CREATE TABLE spatial_data (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255),
    geometry_data GEOMETRY
);

-- Insert a point
INSERT INTO spatial_data (name, geometry_data)
VALUES ('Test Point', ST_GeomFromText('POINT(30 10)'));

-- Insert a linestring
INSERT INTO spatial_data (name, geometry_data)
VALUES ('Test LineString', ST_GeomFromText('LINESTRING(30 10, 40 40, 50 50, 60 60)'));

Add the GEOMETRY data type in the e2e test and check the synchronized results.

Usage Scenario

No response

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions