Skip to content

Commit 2483e80

Browse files
committed
use JSON literals for options parameter
1 parent 1b007b9 commit 2483e80

File tree

5 files changed

+8
-6
lines changed
  • bigframes/core/compile
  • tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_regionstats
  • third_party/bigframes_vendored/ibis

5 files changed

+8
-6
lines changed

bigframes/core/compile/ibis_compiler/operations/geo_ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def st_regionstats(
4242
include = None
4343

4444
if op.options:
45-
options = ibis.literal(op.options, type=ibis_dtypes.string())
45+
options = ibis.literal(op.options, type=ibis_dtypes.json())
4646
else:
4747
options = None
4848

@@ -52,4 +52,4 @@ def st_regionstats(
5252
band=band,
5353
include=include,
5454
options=options,
55-
)
55+
).to_expr()

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,7 @@ def _(
9595
if op.include:
9696
args.append(sge.Kwarg(this="include", expression=sge.convert(op.include)))
9797
if op.options:
98-
args.append(sge.Kwarg(this="options", expression=sge.convert(op.options)))
98+
args.append(
99+
sge.Kwarg(this="options", expression=sge.JSON(this=sge.convert(op.options)))
100+
)
99101
return sge.func("ST_REGIONSTATS", *args)

tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_regionstats/out.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ WITH `bfcte_0` AS (
1010
'ee://some/raster/uri',
1111
band => 'band1',
1212
include => 'some equation',
13-
options => '{"scale": 100}'
13+
options => JSON '{"scale": 100}'
1414
) AS `bfcol_2`
1515
FROM `bfcte_0`
1616
), `bfcte_2` AS (

third_party/bigframes_vendored/ibis/backends/sql/compilers/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ def visit_DefaultLiteral(self, op, *, value, dtype):
811811
elif dtype.is_uuid():
812812
return self.cast(str(value), dtype)
813813
elif dtype.is_json():
814-
return sge.ParseJSON(this=sge.convert(str(value)))
814+
return sge.JSON(this=sge.convert(str(value)))
815815
elif dtype.is_geospatial():
816816
wkt = value if isinstance(value, str) else value.wkt
817817
return self.f.st_geogfromtext(wkt)

third_party/bigframes_vendored/ibis/expr/operations/geospatial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ class GeoRegionStats(GeoSpatialUnOp):
350350
raster_id: Value[dt.String]
351351
band: Value[dt.String]
352352
include: Value[dt.String]
353-
options: Value[dt.String]
353+
options: Value[dt.JSON]
354354

355355
dtype = dt.Struct(
356356
fields={

0 commit comments

Comments
 (0)