Skip to content

Commit 42c8586

Browse files
committed
fix domain for log
1 parent c7438c2 commit 42c8586

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

bigframes/core/compile/polars/operations/numeric_ops.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def ln_op_impl(
4646
) -> pl.Expr:
4747
import polars as pl
4848

49-
return pl.when(input < 0).then(float("nan")).otherwise(input.log())
49+
return pl.when(input <= 0).then(float("nan")).otherwise(input.log())
5050

5151

5252
@polars_compiler.register_op(numeric_ops.Log10Op)
@@ -57,7 +57,7 @@ def log10_op_impl(
5757
) -> pl.Expr:
5858
import polars as pl
5959

60-
return pl.when(input < 0).then(float("nan")).otherwise(input.log(base=10))
60+
return pl.when(input <= 0).then(float("nan")).otherwise(input.log(base=10))
6161

6262

6363
@polars_compiler.register_op(numeric_ops.Log1pOp)
@@ -68,7 +68,7 @@ def log1p_op_impl(
6868
) -> pl.Expr:
6969
import polars as pl
7070

71-
return pl.when(input < -1).then(float("nan")).otherwise((input + 1).log())
71+
return pl.when(input <= -1).then(float("nan")).otherwise((input + 1).log())
7272

7373

7474
@polars_compiler.register_op(numeric_ops.SinOp)
@@ -88,4 +88,4 @@ def sqrt_op_impl(
8888
) -> pl.Expr:
8989
import polars as pl
9090

91-
return pl.when(input < 0).then(float("nan")).otherwise(input.sqrt())
91+
return pl.when(input <= 0).then(float("nan")).otherwise(input.sqrt())

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def _(expr: TypedExpr) -> sge.Expression:
158158
return sge.Case(
159159
ifs=[
160160
sge.If(
161-
this=expr.expr < sge.convert(0),
161+
this=expr.expr <= sge.convert(0),
162162
true=constants._NAN,
163163
)
164164
],
@@ -171,7 +171,7 @@ def _(expr: TypedExpr) -> sge.Expression:
171171
return sge.Case(
172172
ifs=[
173173
sge.If(
174-
this=expr.expr < sge.convert(0),
174+
this=expr.expr <= sge.convert(0),
175175
true=constants._NAN,
176176
)
177177
],
@@ -184,7 +184,7 @@ def _(expr: TypedExpr) -> sge.Expression:
184184
return sge.Case(
185185
ifs=[
186186
sge.If(
187-
this=expr.expr < sge.convert(-1),
187+
this=expr.expr <= sge.convert(-1),
188188
true=constants._NAN,
189189
)
190190
],
@@ -207,7 +207,7 @@ def _(expr: TypedExpr) -> sge.Expression:
207207
return sge.Case(
208208
ifs=[
209209
sge.If(
210-
this=expr.expr < sge.convert(0),
210+
this=expr.expr <= sge.convert(0),
211211
true=constants._NAN,
212212
)
213213
],

0 commit comments

Comments
 (0)