This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sedona.git
The following commit(s) were added to refs/heads/master by this push:
new 69e95a95f9 [GH-2702] Fix ST_LineMerge returning empty collection for
LineString input (#2707)
69e95a95f9 is described below
commit 69e95a95f90af9d86e2f2f42fbe7d3d4f1776a8d
Author: Jia Yu <[email protected]>
AuthorDate: Tue Mar 10 23:16:50 2026 -0700
[GH-2702] Fix ST_LineMerge returning empty collection for LineString input
(#2707)
---
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") {