Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit a66c4db

Browse files
fix issues
1 parent d8bb520 commit a66c4db

File tree

3 files changed

+17
-37
lines changed

3 files changed

+17
-37
lines changed

bigframes/core/compile/ibis_compiler/scalar_op_registry.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ def timedelta_floor_op_impl(x: ibis_types.NumericValue):
10371037
@scalar_op_compiler.register_unary_op(ops.RemoteFunctionOp, pass_op=True)
10381038
def remote_function_op_impl(x: ibis_types.Value, op: ops.RemoteFunctionOp):
10391039
udf_sig = op.function_def.signature
1040-
ibis_py_sig = ((arg.py_type for arg in udf_sig.inputs), udf_sig.output.py_type)
1040+
ibis_py_sig = (tuple(arg.py_type for arg in udf_sig.inputs), udf_sig.output.py_type)
10411041

10421042
@ibis_udf.scalar.builtin(
10431043
name=str(op.function_def.routine_ref), signature=ibis_py_sig
@@ -1056,7 +1056,7 @@ def binary_remote_function_op_impl(
10561056
x: ibis_types.Value, y: ibis_types.Value, op: ops.BinaryRemoteFunctionOp
10571057
):
10581058
udf_sig = op.function_def.signature
1059-
ibis_py_sig = ((arg.py_type for arg in udf_sig.inputs), udf_sig.output.py_type)
1059+
ibis_py_sig = (tuple(arg.py_type for arg in udf_sig.inputs), udf_sig.output.py_type)
10601060

10611061
@ibis_udf.scalar.builtin(
10621062
name=str(op.function_def.routine_ref), signature=ibis_py_sig
@@ -1073,7 +1073,7 @@ def nary_remote_function_op_impl(
10731073
*operands: ibis_types.Value, op: ops.NaryRemoteFunctionOp
10741074
):
10751075
udf_sig = op.function_def.signature
1076-
ibis_py_sig = ((arg.py_type for arg in udf_sig.inputs), udf_sig.output.py_type)
1076+
ibis_py_sig = (tuple(arg.py_type for arg in udf_sig.inputs), udf_sig.output.py_type)
10771077
arg_names = tuple(arg.name for arg in udf_sig.inputs)
10781078

10791079
@ibis_udf.scalar.builtin(

bigframes/functions/_function_client.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ def provision_bq_remote_function(
641641
cloud_function_name = get_cloud_function_name(
642642
cloud_func_spec,
643643
session_id=self._session.session_id if (name is None) else None,
644-
uniq_suffix=random_suffix if reuse is False else None,
644+
uniq_suffix=random_suffix if (not reuse) else None,
645645
)
646646

647647
cf_endpoint = self.get_cloud_function_endpoint(cloud_function_name)
@@ -659,32 +659,29 @@ def provision_bq_remote_function(
659659
max_batching_rows=max_batching_rows,
660660
signature=func_signature,
661661
)
662-
# Override value-derived name if reuse is False, or if name is explicitly provided.
663-
# If reuse is False, then attach a unique suffix to the intended
664-
# function name to make it unique.
665-
rf_name = get_bigframes_function_name(
662+
remote_function_name = name or get_bigframes_function_name(
666663
intended_rf_spec,
667-
self._session.session_id if (name is None) else None,
668-
random_suffix if reuse is False else None,
664+
self._session.session_id,
665+
random_suffix if (not reuse) else None,
669666
)
670667

671668
if reuse:
672-
existing_rf_spec = self.get_remote_function_specs(rf_name)
669+
existing_rf_spec = self.get_remote_function_specs(remote_function_name)
673670
# Create the BQ remote function in following circumstances:
674671
# 1. It does not exist
675672
# 2. It exists but the existing remote function has different
676673
# configuration than intended
677674
created_new = False
678675
if not existing_rf_spec or (existing_rf_spec != intended_rf_spec):
679-
self.create_bq_remote_function(rf_name, intended_rf_spec)
676+
self.create_bq_remote_function(remote_function_name, intended_rf_spec)
680677
created_new = True
681678
else:
682-
logger.info(f"Remote function {rf_name} already exists.")
679+
logger.info(f"Remote function {remote_function_name} already exists.")
683680

684-
return rf_name, cloud_function_name, created_new
681+
return remote_function_name, cloud_function_name, created_new
685682
else:
686-
self.create_bq_remote_function(rf_name, intended_rf_spec)
687-
return rf_name, cloud_function_name, True
683+
self.create_bq_remote_function(remote_function_name, intended_rf_spec)
684+
return remote_function_name, cloud_function_name, True
688685

689686
def get_remote_function_specs(
690687
self, remote_function_name: str

bigframes/functions/udf_def.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ def bf_type(self) -> bigframes.dtypes.Dtype:
106106

107107
@property
108108
def sql_type(self) -> str:
109-
return function_typing.sdk_type_from_python_type(self._py_type).type_kind.name
109+
type_kind = function_typing.sdk_type_from_python_type(self._py_type)
110+
assert type_kind is not None
111+
return type_kind.name
110112

111113
def stable_hash(self) -> bytes:
112114
hash_val = hashlib.md5()
@@ -131,9 +133,7 @@ def py_type(self) -> Type[list[Any]]:
131133
# TODO: Specify emulating type and mapping expressions between said types
132134
@property
133135
def bf_type(self) -> bigframes.dtypes.Dtype:
134-
return bigframes.dtypes.list_type(
135-
function_typing.sdk_type_to_bf_type(self.inner_dtype)
136-
)
136+
return bigframes.dtypes.list_type(self.inner_dtype.bf_type)
137137

138138
@property
139139
def emulating_type(self) -> DirectScalarType:
@@ -259,14 +259,6 @@ def from_routine(cls, routine: bigquery.Routine) -> UdfSignature:
259259
"a type is supported as python output type.",
260260
)
261261

262-
if (
263-
return_type.sql_type
264-
not in function_typing.RF_SUPPORTED_IO_BIGQUERY_TYPEKINDS
265-
):
266-
raise ValueError(
267-
f"Remote function must have one of the following supported output types: {function_typing.RF_SUPPORTED_IO_BIGQUERY_TYPEKINDS}"
268-
)
269-
270262
## Handle input types
271263
udf_fields = []
272264
for argument in routine.arguments:
@@ -335,15 +327,6 @@ def with_devirtualize(self) -> BigqueryUdf:
335327
@classmethod
336328
def from_routine(cls, routine: bigquery.Routine) -> BigqueryUdf:
337329
signature = UdfSignature.from_routine(routine)
338-
339-
if (
340-
signature.output.sql_type is None
341-
or signature.output.sql_type
342-
not in function_typing.RF_SUPPORTED_IO_BIGQUERY_TYPEKINDS
343-
):
344-
raise ValueError(
345-
f"Remote function must have one of the following supported output types: {function_typing.RF_SUPPORTED_IO_BIGQUERY_TYPEKINDS}"
346-
)
347330
return cls(routine.reference, signature=signature)
348331

349332

0 commit comments

Comments
 (0)