Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit f0a1f5b

Browse files
committed
add detailed steps
1 parent 34ed033 commit f0a1f5b

1 file changed

Lines changed: 32 additions & 9 deletions

File tree

specs/2025-08-04-geoseries-scalars.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,38 @@ Raster functions: Functions for analyzing geospatial rasters using geographies.
258258
*Break down the implementation into small, actionable steps.*
259259
*This section will guide the development process.*
260260

261-
### 1. Step One
262-
263-
- [ ] Action 1.1
264-
- [ ] Action 1.2
265-
266-
### 2. Step Two
267-
268-
- [ ] Action 2.1
269-
- [ ] Action 2.2
261+
### Implementing a new scalar geography operation
262+
263+
- [ ] **Define the operation dataclass:**
264+
- [ ] In `bigframes/operations/geo_ops.py`, create a new dataclass inheriting from `base_ops.UnaryOp` or `base_ops.BinaryOp`.
265+
- [ ] Define the `name` of the operation and any parameters it requires.
266+
- [ ] Implement the `output_type` method to specify the data type of the result.
267+
- [ ] **Export the new operation:**
268+
- [ ] In `bigframes/operations/__init__.py`, import your new operation dataclass and add it to the `__all__` list.
269+
- [ ] **Implement the compilation logic:**
270+
- [ ] In `bigframes/core/compile/scalar_op_compiler.py`:
271+
- [ ] If the BigQuery function has a direct equivalent in Ibis, you can often reuse an existing Ibis method.
272+
- [ ] If not, define a new Ibis UDF using `@ibis_udf.scalar.builtin` to map to the specific BigQuery function signature.
273+
- [ ] Create a new compiler implementation function (e.g., `geo_length_op_impl`).
274+
- [ ] Register this function to your operation dataclass using `@scalar_op_compiler.register_unary_op` or `@scalar_op_compiler.register_binary_op`.
275+
- [ ] **Implement the user-facing function or property:**
276+
- [ ] For a `bigframes.bigquery` function:
277+
- [ ] In `bigframes/bigquery/_operations/geo.py`, create the user-facing function (e.g., `st_length`).
278+
- [ ] The function should take a `Series` and any other parameters.
279+
- [ ] Inside the function, call `series._apply_unary_op` or `series._apply_binary_op`, passing the operation dataclass you created.
280+
- [ ] Add a comprehensive docstring with examples.
281+
- [ ] In `bigframes/bigquery/__init__.py`, import your new user-facing function and add it to the `__all__` list.
282+
- [ ] For a `GeoSeries` property or method:
283+
- [ ] In `bigframes/geopandas/geoseries.py`, create the property or method.
284+
- [ ] If the operation is not possible to be supported, such as if the
285+
geopandas method returns values in units corresponding to the
286+
coordinate system rather than meters that BigQuery uses, raise a
287+
`NotImplementedError` with a helpful message.
288+
- [ ] Otherwise, call `series._apply_unary_op` or `series._apply_binary_op`, passing the operation dataclass.
289+
- [ ] Add a comprehensive docstring with examples.
290+
- [ ] **Add Tests:**
291+
- [ ] Add system tests in `tests/system/small/bigquery/test_geo.py` or `tests/system/small/geopandas/test_geoseries.py` to verify the end-to-end functionality. Test various inputs, including edge cases and `NULL` values.
292+
- [ ] If you are overriding a pandas or GeoPandas property and raising `NotImplementedError`, add a unit test to ensure the correct error is raised.
270293

271294
## Verification
272295

0 commit comments

Comments
 (0)