Skip to content

Commit b35c579

Browse files
committed
address comments
1 parent 8d84f26 commit b35c579

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def _(expr: TypedExpr) -> sge.Expression:
8383

8484
@register_nary_op(ops.SqlScalarOp, pass_op=True)
8585
def _(*operands: TypedExpr, op: ops.SqlScalarOp) -> sge.Expression:
86-
# TODO: can we include a string in the sqlglot expression without parsing?
8786
return sg.parse_one(
8887
op.sql_template.format(
8988
*[operand.expr.sql(dialect="bigquery") for operand in operands]

bigframes/testing/utils.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,23 @@ def _apply_binary_op(
475475
) -> str:
476476
"""Applies a binary op to the given DataFrame and return the SQL representing
477477
the resulting DataFrame."""
478+
return _apply_nary_op(obj, op, l_arg, r_arg)
479+
480+
481+
def _apply_nary_op(
482+
obj: bpd.DataFrame,
483+
op: Union[ops.BinaryOp, ops.NaryOp],
484+
*args: Union[str, ex.Expression],
485+
) -> str:
486+
"""Applies a nary op to the given DataFrame and return the SQL representing
487+
the resulting DataFrame."""
478488
array_value = obj._block.expr
479-
op_expr = op.as_expr(l_arg, r_arg)
489+
op_expr = op.as_expr(*args)
480490
result, col_ids = array_value.compute_values([op_expr])
481491

482492
# Rename columns for deterministic golden SQL results.
483493
assert len(col_ids) == 1
484-
result = result.rename_columns({col_ids[0]: l_arg}).select_columns([l_arg])
494+
result = result.rename_columns({col_ids[0]: args[0]}).select_columns([args[0]])
485495

486496
sql = result.session._executor.to_sql(result, enable_cache=False)
487497
return sql

0 commit comments

Comments
 (0)