Skip to content

Conversation

@yzeng1618
Copy link
Contributor

Purpose of this pull request

Fix issue #10155 where PostgreSQL-CDC → JDBC sink failed on GEOMETRY columns because Debezium Geometry/Geography values were serialized as Struct{wkb=...,srid=...} strings and then written as VARCHAR into geometry fields. This PR converts Debezium geometry to hex WKB strings and writes them using PGobject, and adds unit/e2e tests for the full path.

Does this PR introduce any user-facing change?

Yes. For PostgreSQL-CDC + JDBC sink jobs, GEOMETRY/GEOGRAPHY columns can now be synchronized correctly without type mismatch errors. There is no configuration change; behavior is fixed for existing pipelines that previously failed on geometry types.

How was this patch tested?

Added/updated unit tests:

  • SeaTunnelRowDebeziumDeserializationConvertersTest to verify Debezium Geometry is converted to \x... hex WKB string.

  • PostgresJdbcRowConverterTest to verify sourceType=geometry fields are written via PGobject("geometry", value) instead of setString.

Extended e2e tests:

  • Updated inventory.sql in connector-cdc-postgres-e2e to add f_geometry/f_geography columns on both source and sink tables (postgres_cdc_table_1, sink_postgres_cdc_table_1, full_types_no_primary_key, full_types_no_primary_key_with_debezium) and initialized them with ST_GeomFromText / ST_GeographyFromText.

Check list

@zhangshenghang
Copy link
Member

Add unit tests for the Geography type

@zhangshenghang
Copy link
Member

Please update the document

if (PG_INET.equalsIgnoreCase(sourceType)
if (sourceType != null
&& (PG_GEOMETRY.equalsIgnoreCase(sourceType)
|| PG_GEOGRAPHY.equalsIgnoreCase(sourceType))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhangshenghang
The sourceType here comes from source. Are you sure there is no problem? The logic code here only applies to pgsql-cdc ->pgsql. The sourceType should come from sink to apply to all sources. Please take a look at this PR: #10076

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out, the original implementation was indeed taking sourceType from the source tableSchema, so the special handling mainly worked for the pgsql-cdc -> pgsql case.

I’ve updated PostgresJdbcRowConverter.toExternal to resolve the type from the sink first:

  • use databaseTableSchema (sink schema) by column name when it’s available
  • fall back to the original tableSchema sourceType array only for backward compatibility

@yzeng1618 yzeng1618 requested a review from chl-wxp December 16, 2025 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants