[GH-2702] Fix ST_LineMerge returning empty collection for LineString input#2707
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes ST_LineMerge to match PostGIS/GEOS behavior by returning a LineString input unchanged instead of incorrectly producing GEOMETRYCOLLECTION EMPTY.
Changes:
- Add an early
LineStringtype check inFunctions.lineMerge()to return the input geometry as-is. - Extend the existing Spark SQL Scala test for
ST_LineMergeto coverLineStringpassthrough behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| common/src/main/java/org/apache/sedona/common/Functions.java | Fixes lineMerge behavior for LineString inputs by returning them unchanged. |
| spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala | Adds a regression test case to ensure ST_LineMerge preserves LineString inputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1199
to
+1201
| if (geometry instanceof LineString) { | ||
| return geometry; | ||
| } |
There was a problem hiding this comment.
The PR description’s “Behavior after fix” table appears corrupted/duplicated (truncated rows like “Returned unchanch| …”). Please clean up the PR description so reviewers can clearly see the intended behavior matrix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Did you read the Contributor Guide?
Is this PR related to a ticket?
[GH-XXX] my subject. Closes ST_LineMerge returns GEOMETRYCOLLECTION EMPTY for LineString input instead of passing it through #2702What changes were proposed in this PR?
ST_LineMergereturnsGEOMETRYCOLLECTION EMPTYforLineStringinput instead of passing it through unchanged. This is inconsistent with PostGIS/GEOS behavior, where a singleLineStringis already "merged" and should be returned as-is.Fix: Added a
LineStringinstanceof check inFunctions.lineMerge()before theMultiLineStringblock, so that a singleLineStringis returned unchanged.Behavior after fix:
LineStringGEOMETRYCOLLECTION EMPTY)LineStringAll 223 tests in
functionTestScalapass locally. No regressions.Did this PR include necessary documentation updates?