Skip to content

Commit fb5e036

Browse files
committed
switch _INF _FLOAT64_EXP_BOUND
1 parent 925ceb4 commit fb5e036

File tree

3 files changed

+14
-6
lines changed
  • bigframes/core/compile/sqlglot/expressions
  • tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler

3 files changed

+14
-6
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ def _(op: ops.base_ops.UnaryOp, expr: TypedExpr) -> sge.Expression:
200200
return sge.Case(
201201
ifs=[
202202
sge.If(
203-
this=expr.expr > sge.convert(709.78),
204-
true=sge.func("IEEE_DIVIDE", sge.convert(1), sge.convert(0)),
203+
this=expr.expr > _FLOAT64_EXP_BOUND,
204+
true=_INF,
205205
)
206206
],
207207
default=sge.func("EXP", expr.expr),
@@ -213,8 +213,8 @@ def _(op: ops.base_ops.UnaryOp, expr: TypedExpr) -> sge.Expression:
213213
return sge.Case(
214214
ifs=[
215215
sge.If(
216-
this=expr.expr > sge.convert(709.78),
217-
true=sge.func("IEEE_DIVIDE", sge.convert(1), sge.convert(0)),
216+
this=expr.expr > _FLOAT64_EXP_BOUND,
217+
true=_INF,
218218
)
219219
],
220220
default=sge.func("EXP", expr.expr),

tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_exp/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 `bfcol_0` > 709.78 THEN IEEE_DIVIDE(1, 0) ELSE EXP(`bfcol_0`) END AS `bfcol_1`
8+
CASE
9+
WHEN `bfcol_0` > 709.78
10+
THEN CAST('Infinity' AS FLOAT64)
11+
ELSE EXP(`bfcol_0`)
12+
END AS `bfcol_1`
913
FROM `bfcte_0`
1014
)
1115
SELECT

tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_expm1/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 `bfcol_0` > 709.78 THEN IEEE_DIVIDE(1, 0) ELSE EXP(`bfcol_0`) END - 1 AS `bfcol_1`
8+
CASE
9+
WHEN `bfcol_0` > 709.78
10+
THEN CAST('Infinity' AS FLOAT64)
11+
ELSE EXP(`bfcol_0`)
12+
END - 1 AS `bfcol_1`
913
FROM `bfcte_0`
1014
)
1115
SELECT

0 commit comments

Comments
 (0)