Skip to content

Commit 4252e90

Browse files
committed
move to geo_ops
1 parent 745211e commit 4252e90

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,22 @@ def _(expr: TypedExpr) -> sge.Expression:
8282
@register_unary_op(ops.geo_y_op)
8383
def _(expr: TypedExpr) -> sge.Expression:
8484
return sge.func("SAFE.ST_Y", expr.expr)
85+
86+
87+
@register_unary_op(ops.StRegionStatsOp, pass_op=True)
88+
def _(
89+
geography: TypedExpr,
90+
op: ops.StRegionStatsOp,
91+
):
92+
args = [geography.expr] # TODO: get raster, band, include from op.
93+
if op.options:
94+
args.append(
95+
sge.Anonymous(
96+
this="_",
97+
expressions=[
98+
sge.Identifier(this="OPTIONS"),
99+
sge.Anonymous(this="JSON", expressions=[sge.convert(op.options)]),
100+
],
101+
)
102+
)
103+
return sge.func("ST_REGIONSTATS", *args)

bigframes/core/compile/sqlglot/scalar_compiler.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import bigframes.core.compile.sqlglot.sqlglot_ir as ir
2323
import bigframes.core.expression as ex
2424
import bigframes.operations as ops
25-
import bigframes.operations.geo_ops as geo_ops
2625

2726

2827
class ScalarOpCompiler:
@@ -228,22 +227,3 @@ def _add_parentheses(cls, expr: TypedExpr) -> TypedExpr:
228227

229228
# Singleton compiler
230229
scalar_op_compiler = ScalarOpCompiler()
231-
232-
233-
@scalar_op_compiler.register_unary_op(geo_ops.StRegionStatsOp, pass_op=True)
234-
def compile_st_regionstats(
235-
geography: TypedExpr,
236-
op: geo_ops.StRegionStatsOp,
237-
):
238-
args = [geography.expr] # TODO: get raster, band, include from op.
239-
if op.options:
240-
args.append(
241-
sge.Anonymous(
242-
this="_",
243-
expressions=[
244-
sge.Identifier(this="OPTIONS"),
245-
sge.Anonymous(this="JSON", expressions=[sge.convert(op.options)]),
246-
],
247-
)
248-
)
249-
return sge.func("ST_REGIONSTATS", *args)

0 commit comments

Comments
 (0)