Copilot commented on code in PR #517:
URL: https://github.com/apache/sedona-db/pull/517#discussion_r2692102463
##########
python/sedonadb/tests/test_sjoin.py:
##########
@@ -14,9 +14,16 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-import pytest
+
import json
+
+import geopandas as gpd
+import numpy as np
+import pandas as pd
+import pytest
from sedonadb.testing import PostGIS, SedonaDB
+from shapely.geometry import Point
+import warnings
Review Comment:
The import statement for 'warnings' should be grouped with other standard
library imports. Move this line to appear after line 18 (after 'import json')
to maintain proper import ordering (standard library, third-party, local).
##########
python/sedonadb/tests/test_sjoin.py:
##########
@@ -227,3 +234,48 @@ def test_non_optimizable_subquery():
sedonadb_results = eng_sedonadb.execute_and_collect(sql).to_pandas()
assert len(sedonadb_results) > 0
eng_postgis.assert_query_result(sql, sedonadb_results)
+
+
+def test_spatial_join_with_pandas_metadata(con):
+ # Previous versions of SedonaDB failed to execute this because of a
mismatched
+ # schema. Attempts to simplify this reproducer weren't able to recreate the
+ # initial error (PhysicalOptimizer rule 'join_selection' failed).
+ # https://github.com/apache/sedona-db/issues/477
+
+ # 1. Generate Data
+ n_points = 1000
+ n_polys = 10
+
+ # Points
+ rng = np.random.Generator(np.random.MT19937(49791))
+ lons = rng.uniform(-6, 2, n_points)
+ lats = rng.uniform(50, 59, n_points)
+ pts_df = pd.DataFrame(
+ {"idx": range(n_points), "geometry": [Point(x, y) for x, y in
zip(lons, lats)]}
+ )
+ pts_gdf = gpd.GeoDataFrame(pts_df, crs="EPSG:4326")
+
+ # Polygons (Centers buffered)
+ plons = rng.uniform(-6, 2, n_polys)
+ plats = rng.uniform(50, 59, n_polys)
+ poly_centers = gpd.GeoDataFrame(
+ {"geometry": [Point(x, y) for x, y in zip(plons, plats)]},
crs="EPSG:4326"
+ )
+ # Simple buffer in degrees (test data so we don't need the GeoPandas
warning here)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
+ polys_gdf = poly_centers.buffer(0.1).to_frame(name="geometry")
+
+ # 2. Load
+ con.create_data_frame(pts_gdf).to_view("points", overwrite=True)
+ con.create_data_frame(polys_gdf).to_view("polygons", overwrite=True)
+
+ # 4. Intersection
Review Comment:
Comment numbering is inconsistent. There are steps 1, 2, and 4, but step 3
is missing. Either add the missing step 3 or renumber step 4 to step 3.
```suggestion
# 3. Intersection
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]