From 38587a463a1b5c6cb2dda446b6fa652543ee6315 Mon Sep 17 00:00:00 2001 From: Trevor Bergeron Date: Wed, 19 Mar 2025 23:12:42 +0000 Subject: [PATCH 1/2] feat: Support window partition by geo column --- bigframes/core/compile/compiled.py | 6 ++++-- tests/system/small/geopandas/test_geoseries.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/bigframes/core/compile/compiled.py b/bigframes/core/compile/compiled.py index c3d4c10267..c059f1eb29 100644 --- a/bigframes/core/compile/compiled.py +++ b/bigframes/core/compile/compiled.py @@ -674,9 +674,11 @@ def _join_condition( def _as_groupable(value: ibis_types.Value): - # Some types need to be converted to string to enable groupby - if value.type().is_float64() or value.type().is_geospatial(): + # Some types need to be converted to another type to enable groupby + if value.type().is_float64(): return value.cast(ibis_dtypes.str) + elif value.type().is_geospatial(): + return value.as_binary() elif value.type().is_json(): return scalar_op_compiler.to_json_string(value) else: diff --git a/tests/system/small/geopandas/test_geoseries.py b/tests/system/small/geopandas/test_geoseries.py index d0987dbdaf..9ee64b82b9 100644 --- a/tests/system/small/geopandas/test_geoseries.py +++ b/tests/system/small/geopandas/test_geoseries.py @@ -194,3 +194,20 @@ def test_geo_boundary(): check_series_type=False, check_index=False, ) + + +def test_geo_drop_duplicates(): + bf_series = bigframes.geopandas.GeoSeries( + [Point(1, 1), Point(2, 2), Point(3, 3), Point(2, 2)] + ) + + pd_series = geopandas.GeoSeries( + [Point(1, 1), Point(2, 2), Point(3, 3), Point(2, 2)] + ) + + bf_result = bf_series.drop_duplicates().to_pandas() + pd_result = pd_series.drop_duplicates() + + pd.testing.assert_series_equal( + geopandas.GeoSeries(bf_result), pd_result, check_index=False + ) From 94013706f0bcab023c455481482f94a56494f915 Mon Sep 17 00:00:00 2001 From: Trevor Bergeron Date: Wed, 19 Mar 2025 23:16:29 +0000 Subject: [PATCH 2/2] mypy appeasement --- bigframes/core/compile/compiled.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigframes/core/compile/compiled.py b/bigframes/core/compile/compiled.py index c059f1eb29..d4aacdb9af 100644 --- a/bigframes/core/compile/compiled.py +++ b/bigframes/core/compile/compiled.py @@ -678,7 +678,7 @@ def _as_groupable(value: ibis_types.Value): if value.type().is_float64(): return value.cast(ibis_dtypes.str) elif value.type().is_geospatial(): - return value.as_binary() + return typing.cast(ibis_types.GeoSpatialColumn, value).as_binary() elif value.type().is_json(): return scalar_op_compiler.to_json_string(value) else: