File tree Expand file tree Collapse file tree 2 files changed +19
-20
lines changed
bigframes/core/compile/sqlglot Expand file tree Collapse file tree 2 files changed +19
-20
lines changed Original file line number Diff line number Diff line change @@ -82,3 +82,22 @@ def _(expr: TypedExpr) -> sge.Expression:
8282@register_unary_op (ops .geo_y_op )
8383def _ (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 )
Original file line number Diff line number Diff line change 2222import bigframes .core .compile .sqlglot .sqlglot_ir as ir
2323import bigframes .core .expression as ex
2424import bigframes .operations as ops
25- import bigframes .operations .geo_ops as geo_ops
2625
2726
2827class ScalarOpCompiler :
@@ -228,22 +227,3 @@ def _add_parentheses(cls, expr: TypedExpr) -> TypedExpr:
228227
229228# Singleton compiler
230229scalar_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 )
You can’t perform that action at this time.
0 commit comments