Skip to content

Commit bf1f5c6

Browse files
fix bool numeric cast
1 parent 81ade4d commit bf1f5c6

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

packages/bigframes/bigframes/core/compile/lowering.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,11 @@ def _lower_cast_to_substrait(
482482
"substrait-datafusion", "substrait-acero"
483483
] = "substrait-datafusion",
484484
):
485+
if arg.output_type == dtypes.BOOL_DTYPE and dtypes.is_numeric(cast_op.to_type):
486+
# bool -> decimal/numeric needs two-step cast
487+
new_arg = ops.AsTypeOp(to_type=dtypes.INT_DTYPE).as_expr(arg)
488+
return cast_op.as_expr(new_arg)
489+
485490
if arg.output_type == dtypes.BOOL_DTYPE and cast_op.to_type == dtypes.STRING_DTYPE:
486491
is_true_cond = ops.eq_op.as_expr(arg, expression.const(True))
487492
is_false_cond = ops.eq_op.as_expr(arg, expression.const(False))

0 commit comments

Comments
 (0)