Skip to content

Commit e8e0ce5

Browse files
committed
add backtick
1 parent 926a9af commit e8e0ce5

File tree

2 files changed

+8
-2
lines changed
  • bigframes/core/compile/sqlglot/expressions
  • tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_binary_remote_function_op

2 files changed

+8
-2
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,13 @@ def _(left: TypedExpr, right: TypedExpr) -> sge.Expression:
144144
def _(
145145
left: TypedExpr, right: TypedExpr, op: ops.BinaryRemoteFunctionOp
146146
) -> sge.Expression:
147-
return sge.func(str(op.function_def.routine_ref), left.expr, right.expr)
147+
routine_ref = op.function_def.routine_ref
148+
# Quote project, dataset, and routine IDs to avoid keyword clashes.
149+
func_name = (
150+
f"`{routine_ref.project}`.`{routine_ref.dataset_id}`.`{routine_ref.routine_id}`"
151+
)
152+
153+
return sge.func(func_name, left.expr, right.expr)
148154

149155

150156
@register_nary_op(ops.case_when_op)

tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_binary_remote_function_op/out.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ WITH `bfcte_0` AS (
66
), `bfcte_1` AS (
77
SELECT
88
*,
9-
my_project.my_dataset.my_routine(`int64_col`, `float64_col`) AS `bfcol_2`
9+
`my_project`.`my_dataset`.`my_routine`(`int64_col`, `float64_col`) AS `bfcol_2`
1010
FROM `bfcte_0`
1111
)
1212
SELECT

0 commit comments

Comments
 (0)