Skip to content

Commit

Permalink
Translate BinOp.Add between strings to ConcatHorizontal
Browse files Browse the repository at this point in the history
This immediately raises, but previously we had a runtime error.
  • Loading branch information
wence- committed Jul 1, 2024
1 parent 697ef9c commit a88b355
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions python/cudf_polars/cudf_polars/dsl/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,13 @@ def _(node: pl_expr.Ternary, visitor: NodeTraverser, dtype: plc.DataType) -> exp
def _(
node: pl_expr.BinaryExpr, visitor: NodeTraverser, dtype: plc.DataType
) -> expr.Expr:
return expr.BinOp(
dtype,
expr.BinOp._MAPPING[node.op],
translate_expr(visitor, n=node.left),
translate_expr(visitor, n=node.right),
)
left = translate_expr(visitor, n=node.left)
right = translate_expr(visitor, n=node.right)
if dtype.id() == plc.TypeId.STRING and node.op == pl_expr.Operator.PLUS:
return expr.StringFunction(
dtype, pl_expr.StringFunction.ConcatHorizontal, (), left, right
)
return expr.BinOp(dtype, expr.BinOp._MAPPING[node.op], left, right)


@_translate_expr.register
Expand Down

0 comments on commit a88b355

Please sign in to comment.