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 e6322d9074 [GH-2242] Geopandas: Remove orderBy in 
query_geometry_column (#2243)
e6322d9074 is described below

commit e6322d907435a142d689697ff0b64a0969583ecd
Author: Peter Nguyen <[email protected]>
AuthorDate: Wed Aug 6 13:32:31 2025 -0700

    [GH-2242] Geopandas: Remove orderBy in query_geometry_column (#2243)
---
 python/sedona/spark/geopandas/base.py                 | 3 +++
 python/sedona/spark/geopandas/geoseries.py            | 2 +-
 python/tests/geopandas/test_geoseries.py              | 6 ++++++
 python/tests/geopandas/test_match_geopandas_series.py | 3 +++
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/python/sedona/spark/geopandas/base.py 
b/python/sedona/spark/geopandas/base.py
index e22c5f876e..471a245eac 100644
--- a/python/sedona/spark/geopandas/base.py
+++ b/python/sedona/spark/geopandas/base.py
@@ -1652,6 +1652,9 @@ class GeoFrame(metaclass=ABCMeta):
 
         The operation works on a 1-to-1 row-wise manner.
 
+        Note: Unlike most functions, intersection may return the unordered 
with respect to the index.
+        If this is important to you, you may call ``sort_index()`` on the 
result.
+
         Parameters
         ----------
         other : Geoseries or geometric object
diff --git a/python/sedona/spark/geopandas/geoseries.py 
b/python/sedona/spark/geopandas/geoseries.py
index 648f6860a0..62004adf63 100644
--- a/python/sedona/spark/geopandas/geoseries.py
+++ b/python/sedona/spark/geopandas/geoseries.py
@@ -681,7 +681,7 @@ class GeoSeries(GeoFrame, pspd.Series):
                 col_expr,
                 scol_for(df, SPARK_DEFAULT_INDEX_NAME),
                 scol_for(df, NATURAL_ORDER_COLUMN_NAME),
-            ).orderBy(SPARK_DEFAULT_INDEX_NAME)
+            )
         # else if is_aggr, we don't select the index columns
         else:
             sdf = df.select(*exprs)
diff --git a/python/tests/geopandas/test_geoseries.py 
b/python/tests/geopandas/test_geoseries.py
index 61ca151317..8c6c8974ac 100644
--- a/python/tests/geopandas/test_geoseries.py
+++ b/python/tests/geopandas/test_geoseries.py
@@ -1520,6 +1520,7 @@ e": "Feature", "properties": {}, "geometry": {"type": 
"Point", "coordinates": [3
             [(-0.5, -0.5), (-0.5, 2.5), (2.5, 2.5), (2.5, -0.5), (-0.5, -0.5)]
         )
         result = s.intersection(geom)
+        result.sort_index(inplace=True)
         expected = gpd.GeoSeries(
             [
                 Polygon([(0, 0), (2, 2), (0, 2)]),
@@ -1541,6 +1542,7 @@ e": "Feature", "properties": {}, "geometry": {"type": 
"Point", "coordinates": [3
             ],
         )
         result = s.intersection(s2)
+        result.sort_index(inplace=True)
         expected = gpd.GeoSeries(
             [
                 Polygon([(0, 0), (0, 1), (1, 1), (0, 0)]),
@@ -1580,6 +1582,7 @@ e": "Feature", "properties": {}, "geometry": {"type": 
"Point", "coordinates": [3
             assert s2.index.equals(expected_index)
 
         result = s.intersection(s2, align=True)
+        result.sort_index(inplace=True)
         expected = gpd.GeoSeries(
             [
                 None,
@@ -1594,9 +1597,11 @@ e": "Feature", "properties": {}, "geometry": {"type": 
"Point", "coordinates": [3
 
         # Check that GeoDataFrame works too
         df_result = s.to_geoframe().intersection(s2, align=True)
+        df_result.sort_index(inplace=True)
         self.check_sgpd_equals_gpd(df_result, expected)
 
         result = s2.intersection(s, align=False)
+        result.sort_index(inplace=True)
         expected = gpd.GeoSeries(
             [
                 Polygon([(0, 0), (0, 1), (1, 1), (0, 0)]),
@@ -1614,6 +1619,7 @@ e": "Feature", "properties": {}, "geometry": {"type": 
"Point", "coordinates": [3
 
         # Check that GeoDataFrame works too
         df_result = s2.to_geoframe().intersection(s, align=False)
+        df_result.sort_index(inplace=True)
         self.check_sgpd_equals_gpd(df_result, expected)
 
     def test_snap(self):
diff --git a/python/tests/geopandas/test_match_geopandas_series.py 
b/python/tests/geopandas/test_match_geopandas_series.py
index c845bf99a0..17cae5b95e 100644
--- a/python/tests/geopandas/test_match_geopandas_series.py
+++ b/python/tests/geopandas/test_match_geopandas_series.py
@@ -810,6 +810,7 @@ class TestMatchGeopandasSeries(TestGeopandasBase):
         sgpd_result = GeoSeries(geometries, index1).intersection(
             GeoSeries(geometries, index2), align=False
         )
+        sgpd_result.sort_index(inplace=True)
 
         gpd_result = gpd.GeoSeries(geometries, index1).intersection(
             gpd.GeoSeries(geometries, index2), align=False
@@ -824,6 +825,7 @@ class TestMatchGeopandasSeries(TestGeopandasBase):
             if not gpd_series1.is_valid.all() or not 
gpd_series2.is_valid.all():
                 continue
             sgpd_result = GeoSeries(geom).intersection(GeoSeries(geom2))
+            sgpd_result.sort_index(inplace=True)
             gpd_result = gpd_series1.intersection(gpd_series2)
             self.check_sgpd_equals_gpd(sgpd_result, gpd_result)
 
@@ -831,6 +833,7 @@ class TestMatchGeopandasSeries(TestGeopandasBase):
                 sgpd_result = GeoSeries(geom).intersection(
                     GeoSeries(geom2), align=False
                 )
+                sgpd_result.sort_index(inplace=True)
                 gpd_result = gpd_series1.intersection(gpd_series2, align=False)
                 self.check_sgpd_equals_gpd(sgpd_result, gpd_result)
 

Reply via email to