Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions bigframes/core/compile/ibis_compiler/scalar_op_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,10 @@ def udf(*inputs):

@scalar_op_compiler.register_unary_op(ops.MapOp, pass_op=True)
def map_op_impl(x: ibis_types.Value, op: ops.MapOp):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please check if the SQLGlot has the same issue: bigframes/core/compile/sqlglot/expressions/generic_ops.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, probably?

# this should probably be handled by a rewriter
if len(op.mappings) == 0:
return x

case = ibis_api.case()
for mapping in op.mappings:
case = case.when(x == mapping[0], mapping[1])
Expand Down
2 changes: 2 additions & 0 deletions bigframes/core/compile/sqlglot/expressions/generic_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def _(expr: TypedExpr) -> sge.Expression:

@register_unary_op(ops.MapOp, pass_op=True)
def _(expr: TypedExpr, op: ops.MapOp) -> sge.Expression:
if len(op.mappings) == 0:
return expr.expr
return sge.Case(
this=expr.expr,
ifs=[
Expand Down
2 changes: 2 additions & 0 deletions tests/system/small/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,12 @@ def test_series_replace_nans_with_pd_na(scalars_dfs):
(
({"Hello, World!": "Howdy, Planet!", "T": "R"},),
({},),
({0: "Hello, World!"},),
),
ids=[
"non-empty",
"empty",
"off-type",
],
)
def test_series_replace_dict(scalars_dfs, replacement_dict):
Expand Down