This is an automated email from the ASF dual-hosted git repository. jiayu pushed a commit to branch fix-linemerge-linestring-passthrough in repository https://gitbox.apache.org/repos/asf/sedona.git
commit 2472bca945c4cd61e2abbd047cf4a2528a5b29c1 Author: Jia Yu <[email protected]> AuthorDate: Tue Mar 10 23:04:48 2026 -0700 Fix ST_LineMerge returning empty collection for LineString input ST_LineMerge now passes through a single LineString unchanged, consistent with PostGIS/GEOS behavior. Previously it fell through to the default branch and returned GEOMETRYCOLLECTION EMPTY. Fixes #2702 --- common/src/main/java/org/apache/sedona/common/Functions.java | 3 +++ .../src/test/scala/org/apache/sedona/sql/functionTestScala.scala | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/org/apache/sedona/common/Functions.java b/common/src/main/java/org/apache/sedona/common/Functions.java index 76bea7e695..62232d2e20 100644 --- a/common/src/main/java/org/apache/sedona/common/Functions.java +++ b/common/src/main/java/org/apache/sedona/common/Functions.java @@ -1196,6 +1196,9 @@ public class Functions { } public static Geometry lineMerge(Geometry geometry) { + if (geometry instanceof LineString) { + return geometry; + } if (geometry instanceof MultiLineString) { MultiLineString multiLineString = (MultiLineString) geometry; int numLineStrings = multiLineString.getNumGeometries(); diff --git a/spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala b/spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala index 601a7ccbd9..6e637bd306 100644 --- a/spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala +++ b/spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala @@ -2246,7 +2246,8 @@ class functionTestScala ("MULTILINESTRING ((-29 -27, -30 -29.7, -45 -33), (-45 -33, -46 -32))"), ("MULTILINESTRING ((-29 -27, -30 -29.7, -36 -31, -45 -33), (-45.2 -33.2, -46 -32))"), ("POLYGON ((8 25, 28 22, 15 11, 33 3, 56 30, 47 44, 35 36, 43 19, 24 39, 8 25))"), - ("MULTILINESTRING ((10 160, 60 120), (120 140, 60 120), (120 140, 180 120), (100 180, 120 140))")) + ("MULTILINESTRING ((10 160, 60 120), (120 140, 60 120), (120 140, 180 120), (100 180, 120 140))"), + ("LINESTRING (0 0, 1 1)")) .toDF("Geometry") When("Using ST_LineMerge") @@ -2261,7 +2262,8 @@ class functionTestScala "LINESTRING (-29 -27, -30 -29.7, -45 -33, -46 -32)", "MULTILINESTRING ((-45.2 -33.2, -46 -32), (-29 -27, -30 -29.7, -36 -31, -45 -33))", "GEOMETRYCOLLECTION EMPTY", - "MULTILINESTRING ((10 160, 60 120, 120 140), (100 180, 120 140), (120 140, 180 120))") + "MULTILINESTRING ((10 160, 60 120, 120 140), (100 180, 120 140), (120 140, 180 120))", + "LINESTRING (0 0, 1 1)") } it("Should pass ST_LocateAlong") {
