Skip to content

[GH-3058] Add GeographyTypeSerializer to SedonaFlink - #3059

Merged
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:flink-geography-serde
Jun 19, 2026
Merged

[GH-3058] Add GeographyTypeSerializer to SedonaFlink#3059
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:flink-geography-serde

Conversation

@jiayuasu

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

This is the first step toward Geography type support in SedonaFlink (#3054).

It adds GeographyTypeSerializer, a Flink TypeSerializer<Geography> that lets Geography values flow through the Flink Table/DataStream type system, mirroring the existing GeometryTypeSerializer:

  • Length-prefixed, null-safe binary layout, delegating to org.apache.sedona.common.S2Geography.GeographyWKBSerializer (the same serializer the Spark GeographyUDT uses), so geography bytes are interchangeable across engines.
  • copy(Geography) is implemented via a serialize/deserialize round-trip, since Geography exposes no copy()/clone().
  • A TypeSerializerSnapshot is provided for state schema compatibility, mirroring GeometrySerializerSnapshot.

No user-facing functions are registered yet — the ST_Geog* constructors and Catalog registration follow in a subsequent PR.

How was this patch tested?

Added GeographyTypeSerializerTest, which round-trips geographies through the Flink DataOutputView/DataInputView API:

  • point and polygon round-trips (asserting EWKT and SRID are preserved),
  • null round-trip,
  • copy() for a value and for null.

mvn -pl flink test -Dtest=GeographyTypeSerializerTest → 4 tests pass.

Did this PR include necessary documentation updates?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds initial Flink runtime support for Sedona’s Geography type by introducing a dedicated Flink TypeSerializer<Geography> and accompanying unit tests, mirroring the existing geometry serializer approach in the Flink module.

Changes:

  • Added GeographyTypeSerializer that serializes Geography values as a null-safe, length-prefixed byte payload using GeographyWKBSerializer.
  • Added a TypeSerializerSnapshot implementation for Flink state/schema compatibility.
  • Added GeographyTypeSerializerTest covering point/polygon round-trips, null handling, and copy() behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
flink/src/main/java/org/apache/sedona/flink/GeographyTypeSerializer.java Introduces a Flink TypeSerializer + snapshot for Sedona Geography, using WKB-based encoding with a length prefix and null sentinel.
flink/src/test/java/org/apache/sedona/flink/GeographyTypeSerializerTest.java Adds unit tests validating serialization/deserialization round-trips and copy() behavior for Geography.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone Jun 19, 2026
@jiayuasu
jiayuasu merged commit 005a464 into apache:master Jun 19, 2026
19 checks passed
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.

SedonaFlink: add GeographyTypeSerializer for the Geography type

2 participants