Skip to content

[GH-3177] Add Geography support for ST_MakeLine - #3195

Merged
jiayuasu merged 8 commits into
apache:masterfrom
jiayuasu:feature/geography-make-line
Jul 29, 2026
Merged

[GH-3177] Add Geography support for ST_MakeLine#3195
jiayuasu merged 8 commits into
apache:masterfrom
jiayuasu:feature/geography-make-line

Conversation

@jiayuasu

@jiayuasu jiayuasu commented Jul 28, 2026

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?

  • Add the two-argument Geography overload for ST_MakeLine in Spark and Flink for Point, MultiPoint, and LineString inputs. The array and aggregate forms remain Geometry-only.
  • Preserve the first input Geography's SRID without transforming coordinates or validating that the second input has the same SRID.
  • Match the existing line-assembly behavior: a shared seam is emitted once when the second input is a LineString, while Point and MultiPoint coordinates and other repeated vertices are retained.
  • Treat the stored WKB coordinate sequence as the structural source of truth and build the S2 representation lazily for spherical operations. This prevents S2 edge canonicalization from turning coincident points into an unusable empty line or silently dropping structural vertices.
  • Keep ST_AsText, ST_AsEWKT, ST_NPoints, and WKB round trips consistent with the stored coordinates. ST_AsEWKT(Geography) now uses the stored WKB/JTS representation for all Geography values instead of the fixed-precision S2 writer, so it no longer truncates ordinary input coordinates.
  • Make WKT-created Geography values WKB-backed as well, giving WKT and WKB constructors the same structural behavior.
  • Canonicalize adjacent duplicate polyline vertices only in the derived S2 operational view. A line that collapses to one distinct point remains a non-empty S2 polyline so spherical centroid and envelope operations remain usable.
  • Emit valid WKT/WKB for singleton operational S2 polylines by writing the coordinate twice. This keeps object rendering and serialization parseable while the authoritative stored WKB retains the original structure.
  • Add Spark and Flink documentation, including the supported overloads, repeated-coordinate behavior, great-circle interpretation, and SRID rules.

The S2 operational view can canonicalize internal adjacent duplicates, while SQL structural accessors continue to report the stored WKB coordinates. No function-specific provenance is stored in WKBGeography, and this PR has no net change to WKBGeography.java.

Pre-existing empty-input behavior is outside this change: combining an empty Point or LineString with a non-empty input can still attempt to construct a one-point JTS LineString and fail. ST_Envelope on an empty Point is also unchanged.

How was this patch tested?

  • Full common module suite: 1,176 tests, 0 failures.
  • Focused common Geography and S2 WKB/WKT suites: 158 tests, 0 failures.
  • Spark Geography function suite: 54 tests, 0 failures.
  • Flink Geography function suite: 17 tests, 0 failures.
  • Coincident-point coverage verifies WKB round trips, text output, point count, type, length, distance, centroid, both envelope modes, and reuse as a subsequent ST_MakeLine input.
  • Coverage also includes Point, MultiPoint, and LineString combinations, LineString seam handling, preserved internal repeats, antimeridian length, mismatched and zero SRIDs, nulls, and unsupported inputs.
  • Spotless, pre-commit hooks, and git diff --check passed.

Did this PR include necessary documentation updates?

  • Yes, I am adding a new API using the current SNAPSHOT version number, v1.9.1.
  • Yes, the Spark and Flink Geography function indexes and ST_MakeLine API pages are updated.

@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone Jul 28, 2026
@jiayuasu
jiayuasu marked this pull request as ready for review July 28, 2026 06:15
@jiayuasu
jiayuasu force-pushed the feature/geography-make-line branch from caf40b1 to d99dd55 Compare July 29, 2026 05:42
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

Successfully merging this pull request may close these issues.

Add Geography support for ST_MakeLine

1 participant