Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bigframes/core/compile/sqlglot/expressions/numeric_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ def _(expr: TypedExpr) -> sge.Expression:
return sge.func("ASINH", expr.expr)


@register_binary_op(ops.arctan2_op)
def _(left: TypedExpr, right: TypedExpr) -> sge.Expression:
return sge.func("ATAN2", left.expr, right.expr)


@register_unary_op(ops.arctan_op)
def _(expr: TypedExpr) -> sge.Expression:
return sge.func("ATAN", expr.expr)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
WITH `bfcte_0` AS (
SELECT
`int64_col` AS `bfcol_0`,
`float64_col` AS `bfcol_1`
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types`
), `bfcte_1` AS (
SELECT
*,
ATAN2(`bfcol_0`, `bfcol_1`) AS `bfcol_2`
FROM `bfcte_0`
)
SELECT
`bfcol_2` AS `int64_col`
FROM `bfcte_1`
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def test_arcsinh(scalar_types_df: bpd.DataFrame, snapshot):
snapshot.assert_match(sql, "out.sql")


def test_arctan2(scalar_types_df: bpd.DataFrame, snapshot):
bf_df = scalar_types_df[["int64_col", "float64_col"]]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add "bool_col" and then compare the Ibis results. Sometime, we may need "CAST(bool_col, INT64)" before calculating "ATAN2"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Fixed.

sql = utils._apply_binary_op(bf_df, ops.arctan2_op, "int64_col", "float64_col")

snapshot.assert_match(sql, "out.sql")


def test_arctan(scalar_types_df: bpd.DataFrame, snapshot):
col_name = "float64_col"
bf_df = scalar_types_df[[col_name]]
Expand Down