Skip to content

Commit 7bb8d1e

Browse files
committed
switch _INF _NAN
1 parent b00cb67 commit 7bb8d1e

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _(op: ops.base_ops.UnaryOp, expr: TypedExpr) -> sge.Expression:
4949
ifs=[
5050
sge.If(
5151
this=expr.expr < sge.convert(1),
52-
true=sge.func("IEEE_DIVIDE", sge.convert(0), sge.convert(0)),
52+
true=_NAN,
5353
)
5454
],
5555
default=sge.func("ACOSH", expr.expr),
@@ -98,7 +98,7 @@ def _(op: ops.base_ops.UnaryOp, expr: TypedExpr) -> sge.Expression:
9898
ifs=[
9999
sge.If(
100100
this=sge.func("ABS", expr.expr) > sge.convert(1),
101-
true=sge.func("IEEE_DIVIDE", sge.convert(0), sge.convert(0)),
101+
true=_NAN,
102102
)
103103
],
104104
default=sge.func("ATANH", expr.expr),
@@ -168,7 +168,7 @@ def _(op: ops.base_ops.UnaryOp, expr: TypedExpr) -> sge.Expression:
168168
ifs=[
169169
sge.If(
170170
this=sge.func("ABS", expr.expr) > sge.convert(709.78),
171-
true=sge.func("IEEE_DIVIDE", sge.convert(1), sge.convert(0)),
171+
true=_INF,
172172
)
173173
],
174174
default=sge.func("COSH", expr.expr),

tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arccosh/out.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ WITH `bfcte_0` AS (
55
), `bfcte_1` AS (
66
SELECT
77
*,
8-
CASE WHEN `bfcol_0` < 1 THEN IEEE_DIVIDE(0, 0) ELSE ACOSH(`bfcol_0`) END AS `bfcol_1`
8+
CASE WHEN `bfcol_0` < 1 THEN CAST('NaN' AS FLOAT64) ELSE ACOSH(`bfcol_0`) END AS `bfcol_1`
99
FROM `bfcte_0`
1010
)
1111
SELECT

tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arctanh/out.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ WITH `bfcte_0` AS (
55
), `bfcte_1` AS (
66
SELECT
77
*,
8-
CASE WHEN ABS(`bfcol_0`) > 1 THEN IEEE_DIVIDE(0, 0) ELSE ATANH(`bfcol_0`) END AS `bfcol_1`
8+
CASE WHEN ABS(`bfcol_0`) > 1 THEN CAST('NaN' AS FLOAT64) ELSE ATANH(`bfcol_0`) END AS `bfcol_1`
99
FROM `bfcte_0`
1010
)
1111
SELECT

tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_cosh/out.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ WITH `bfcte_0` AS (
55
), `bfcte_1` AS (
66
SELECT
77
*,
8-
CASE WHEN ABS(`bfcol_0`) > 709.78 THEN IEEE_DIVIDE(1, 0) ELSE COSH(`bfcol_0`) END AS `bfcol_1`
8+
CASE
9+
WHEN ABS(`bfcol_0`) > 709.78
10+
THEN CAST('Infinity' AS FLOAT64)
11+
ELSE COSH(`bfcol_0`)
12+
END AS `bfcol_1`
913
FROM `bfcte_0`
1014
)
1115
SELECT

0 commit comments

Comments
 (0)