Skip to content

Commit 364aaef

Browse files
committed
geo_st_convexhull_op compiler
1 parent 3d2a33b commit 364aaef

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ def _(op: ops.base_ops.UnaryOp, expr: TypedExpr) -> sge.Expression:
278278
return sge.func("ST_CENTROID", expr.expr)
279279

280280

281+
@UNARY_OP_REGISTRATION.register(ops.geo_st_convexhull_op)
282+
def _(op: ops.base_ops.UnaryOp, expr: TypedExpr) -> sge.Expression:
283+
return sge.func("ST_CONVEXHULL", expr.expr)
284+
285+
281286
@UNARY_OP_REGISTRATION.register(ops.geo_st_geogfromtext_op)
282287
def _(op: ops.base_ops.UnaryOp, expr: TypedExpr) -> sge.Expression:
283288
return sge.func("SAFE.ST_GEOGFROMTEXT", expr.expr)
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_CONVEXHULL(`bfcol_0`) 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
@@ -188,6 +188,13 @@ def test_geo_st_centroid(scalar_types_df: bpd.DataFrame, snapshot):
188188
snapshot.assert_match(sql, "out.sql")
189189

190190

191+
def test_geo_st_convexhull(scalar_types_df: bpd.DataFrame, snapshot):
192+
bf_df = scalar_types_df[["geography_col"]]
193+
sql = _apply_unary_op(bf_df, ops.geo_st_convexhull_op, "geography_col")
194+
195+
snapshot.assert_match(sql, "out.sql")
196+
197+
191198
def test_geo_st_geogfromtext(scalar_types_df: bpd.DataFrame, snapshot):
192199
bf_df = scalar_types_df[["string_col"]]
193200
sql = _apply_unary_op(bf_df, ops.geo_st_geogfromtext_op, "string_col")

0 commit comments

Comments
 (0)