diff --git a/bigframes/core/compile/sqlglot/expressions/geo_ops.py b/bigframes/core/compile/sqlglot/expressions/geo_ops.py index fa3053db63..10ccdfbeb3 100644 --- a/bigframes/core/compile/sqlglot/expressions/geo_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/geo_ops.py @@ -60,6 +60,11 @@ def _(expr: TypedExpr) -> sge.Expression: return sge.func("ST_CONVEXHULL", expr.expr) +@register_binary_op(ops.geo_st_geogpoint_op) +def _(left: TypedExpr, right: TypedExpr) -> sge.Expression: + return sge.func("ST_GEOGPOINT", left.expr, right.expr) + + @register_unary_op(ops.geo_st_geogfromtext_op) def _(expr: TypedExpr) -> sge.Expression: return sge.func("SAFE.ST_GEOGFROMTEXT", expr.expr) diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogpoint/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogpoint/out.sql new file mode 100644 index 0000000000..f6c953d161 --- /dev/null +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_geo_ops/test_geo_st_geogpoint/out.sql @@ -0,0 +1,14 @@ +WITH `bfcte_0` AS ( + SELECT + `rowindex`, + `rowindex_2` + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` +), `bfcte_1` AS ( + SELECT + *, + ST_GEOGPOINT(`rowindex`, `rowindex_2`) AS `bfcol_2` + FROM `bfcte_0` +) +SELECT + `bfcol_2` AS `rowindex` +FROM `bfcte_1` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/test_geo_ops.py b/tests/unit/core/compile/sqlglot/expressions/test_geo_ops.py index cce3e726ac..5684ff6f15 100644 --- a/tests/unit/core/compile/sqlglot/expressions/test_geo_ops.py +++ b/tests/unit/core/compile/sqlglot/expressions/test_geo_ops.py @@ -99,6 +99,16 @@ def test_geo_st_geogfromtext(scalar_types_df: bpd.DataFrame, snapshot): snapshot.assert_match(sql, "out.sql") +def test_geo_st_geogpoint(scalar_types_df: bpd.DataFrame, snapshot): + col_names = ["rowindex", "rowindex_2"] + bf_df = scalar_types_df[col_names] + sql = utils._apply_binary_op( + bf_df, ops.geo_st_geogpoint_op, col_names[0], col_names[1] + ) + + snapshot.assert_match(sql, "out.sql") + + def test_geo_st_intersection(scalar_types_df: bpd.DataFrame, snapshot): col_name = "geography_col" bf_df = scalar_types_df[[col_name]]