Skip to content

Commit ef14cad

Browse files
feat: Include remote_function name in generated cloud function name
1 parent 95763ff commit ef14cad

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

bigframes/functions/_function_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,10 @@ def provision_bq_remote_function(
612612
# makes their naming more stable for the same udf code
613613
session_id = None if name else self._session.session_id
614614
cloud_function_name = _utils.get_cloud_function_name(
615-
function_hash, session_id, uniq_suffix
615+
function_hash,
616+
user_given_name=name,
617+
session_id=session_id,
618+
uniq_suffix=uniq_suffix,
616619
)
617620
cf_endpoint = self.get_cloud_function_endpoint(cloud_function_name)
618621

bigframes/functions/_utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,16 @@ def routine_ref_to_string_for_query(routine_ref: bigquery.RoutineReference) -> s
212212
return f"`{routine_ref.project}.{routine_ref.dataset_id}`.{routine_ref.routine_id}"
213213

214214

215-
def get_cloud_function_name(function_hash, session_id=None, uniq_suffix=None):
215+
def get_cloud_function_name(
216+
function_hash: str,
217+
user_given_name: Optional[str] = None,
218+
session_id: Optional[str] = None,
219+
uniq_suffix: Optional[str] = None,
220+
):
216221
"Get a name for the cloud function for the given user defined function."
217222
parts = [_BIGFRAMES_FUNCTION_PREFIX]
223+
if user_given_name:
224+
parts.append(user_given_name)
218225
if session_id:
219226
parts.append(session_id)
220227
parts.append(function_hash)

tests/system/large/functions/test_remote_function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def add_one(x):
530530
package_requirements = bff_utils.get_updated_package_requirements()
531531
add_one_uniq_hash = bff_utils.get_hash(add_one_uniq, package_requirements)
532532
add_one_uniq_cf_name = bff_utils.get_cloud_function_name(
533-
add_one_uniq_hash, session.session_id
533+
add_one_uniq_hash, session_id=session.session_id
534534
)
535535

536536
# There should be no cloud function yet for the unique udf

0 commit comments

Comments
 (0)