From ef14cad5d0dc6cb65e68c6c5aba0b34357ac5300 Mon Sep 17 00:00:00 2001 From: Trevor Bergeron Date: Fri, 16 Jan 2026 22:16:27 +0000 Subject: [PATCH 1/2] feat: Include remote_function name in generated cloud function name --- bigframes/functions/_function_client.py | 5 ++++- bigframes/functions/_utils.py | 9 ++++++++- tests/system/large/functions/test_remote_function.py | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/bigframes/functions/_function_client.py b/bigframes/functions/_function_client.py index a82217da03..f0921efea4 100644 --- a/bigframes/functions/_function_client.py +++ b/bigframes/functions/_function_client.py @@ -612,7 +612,10 @@ def provision_bq_remote_function( # makes their naming more stable for the same udf code session_id = None if name else self._session.session_id cloud_function_name = _utils.get_cloud_function_name( - function_hash, session_id, uniq_suffix + function_hash, + user_given_name=name, + session_id=session_id, + uniq_suffix=uniq_suffix, ) cf_endpoint = self.get_cloud_function_endpoint(cloud_function_name) diff --git a/bigframes/functions/_utils.py b/bigframes/functions/_utils.py index b6dedeac50..f714f1edc1 100644 --- a/bigframes/functions/_utils.py +++ b/bigframes/functions/_utils.py @@ -212,9 +212,16 @@ def routine_ref_to_string_for_query(routine_ref: bigquery.RoutineReference) -> s return f"`{routine_ref.project}.{routine_ref.dataset_id}`.{routine_ref.routine_id}" -def get_cloud_function_name(function_hash, session_id=None, uniq_suffix=None): +def get_cloud_function_name( + function_hash: str, + user_given_name: Optional[str] = None, + session_id: Optional[str] = None, + uniq_suffix: Optional[str] = None, +): "Get a name for the cloud function for the given user defined function." parts = [_BIGFRAMES_FUNCTION_PREFIX] + if user_given_name: + parts.append(user_given_name) if session_id: parts.append(session_id) parts.append(function_hash) diff --git a/tests/system/large/functions/test_remote_function.py b/tests/system/large/functions/test_remote_function.py index 2591c0c13a..83f53f2ab7 100644 --- a/tests/system/large/functions/test_remote_function.py +++ b/tests/system/large/functions/test_remote_function.py @@ -530,7 +530,7 @@ def add_one(x): package_requirements = bff_utils.get_updated_package_requirements() add_one_uniq_hash = bff_utils.get_hash(add_one_uniq, package_requirements) add_one_uniq_cf_name = bff_utils.get_cloud_function_name( - add_one_uniq_hash, session.session_id + add_one_uniq_hash, session_id=session.session_id ) # There should be no cloud function yet for the unique udf From fef3abeceaaea2f0a7fb309e63165c84c82844e8 Mon Sep 17 00:00:00 2001 From: Trevor Bergeron Date: Fri, 16 Jan 2026 22:34:34 +0000 Subject: [PATCH 2/2] fix test_get_cloud_function_name --- .../functions/test_remote_function_utils.py | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/unit/functions/test_remote_function_utils.py b/tests/unit/functions/test_remote_function_utils.py index 812d65bbad..afc796c63e 100644 --- a/tests/unit/functions/test_remote_function_utils.py +++ b/tests/unit/functions/test_remote_function_utils.py @@ -42,16 +42,18 @@ def test_get_remote_function_locations( @pytest.mark.parametrize( - "func_hash, session_id, uniq_suffix, expected_name", + "func_hash, user_given_name, session_id, uniq_suffix, expected_name", [ ( "hash123", + "my_func", None, None, - "bigframes-hash123", + "bigframes-my_func-hash123", ), ( "hash456", + None, "session789", None, "bigframes-session789-hash456", @@ -59,20 +61,29 @@ def test_get_remote_function_locations( ( "hash123", None, + None, "suffixABC", "bigframes-hash123-suffixABC", ), ( "hash456", + "really_cool_udf", "session789", "suffixDEF", - "bigframes-session789-hash456-suffixDEF", + "bigframes-really_cool_udf-session789-hash456-suffixDEF", ), ], ) -def test_get_cloud_function_name(func_hash, session_id, uniq_suffix, expected_name): +def test_get_cloud_function_name( + func_hash, user_given_name, session_id, uniq_suffix, expected_name +): """Tests the construction of the cloud function name from its parts.""" - result = _utils.get_cloud_function_name(func_hash, session_id, uniq_suffix) + result = _utils.get_cloud_function_name( + func_hash, + user_given_name=user_given_name, + session_id=session_id, + uniq_suffix=uniq_suffix, + ) assert result == expected_name