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

Commit 2375c07

Browse files
committed
GeoStBufferOp compiler
1 parent 0c0c3fa commit 2375c07

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

bigframes/core/compile/sqlglot/expressions/unary_compiler.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,17 @@ def _(op: ops.base_ops.UnaryOp, expr: TypedExpr) -> sge.Expression:
262262
return sge.func("ST_BOUNDARY", expr.expr)
263263

264264

265+
@UNARY_OP_REGISTRATION.register(ops.GeoStBufferOp)
266+
def _(op: ops.GeoStBufferOp, expr: TypedExpr) -> sge.Expression:
267+
return sge.func(
268+
"ST_BUFFER",
269+
expr.expr,
270+
sge.convert(op.buffer_radius),
271+
sge.convert(op.num_seg_quarter_circle),
272+
sge.convert(op.use_spheroid),
273+
)
274+
275+
265276
@UNARY_OP_REGISTRATION.register(ops.geo_st_geogfromtext_op)
266277
def _(op: ops.base_ops.UnaryOp, expr: TypedExpr) -> sge.Expression:
267278
return sge.func("SAFE.ST_GEOGFROMTEXT", expr.expr)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
WITH `bfcte_0` AS (
2+
SELECT
3+
`geography_col` AS `bfcol_0`
4+
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types`
5+
), `bfcte_1` AS (
6+
SELECT
7+
*,
8+
ST_BUFFER(`bfcol_0`, 1.0, 8.0, FALSE) AS `bfcol_1`
9+
FROM `bfcte_0`
10+
)
11+
SELECT
12+
`bfcol_1` AS `geography_col`
13+
FROM `bfcte_1`

tests/unit/core/compile/sqlglot/expressions/test_unary_compiler.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ def test_geo_st_boundary(scalar_types_df: bpd.DataFrame, snapshot):
174174
snapshot.assert_match(sql, "out.sql")
175175

176176

177+
def test_geo_st_buffer(scalar_types_df: bpd.DataFrame, snapshot):
178+
bf_df = scalar_types_df[["geography_col"]]
179+
sql = _apply_unary_op(bf_df, ops.GeoStBufferOp(1.0, 8.0, False), "geography_col")
180+
181+
snapshot.assert_match(sql, "out.sql")
182+
183+
177184
def test_geo_st_geogfromtext(scalar_types_df: bpd.DataFrame, snapshot):
178185
bf_df = scalar_types_df[["string_col"]]
179186
sql = _apply_unary_op(bf_df, ops.geo_st_geogfromtext_op, "string_col")

0 commit comments

Comments
 (0)