2525import bigframes
2626import bigframes .dtypes
2727import bigframes .exceptions
28- from bigframes .functions import _utils as rf_utils
29- from bigframes .functions import remote_function as rf
28+ from bigframes .functions import _utils as bff_utils
29+ from bigframes .functions import function as bff
3030from tests .system .utils import assert_pandas_df_equal
3131
3232_prefixer = test_utils .prefixer .Prefixer ("bigframes" , "" )
@@ -94,12 +94,12 @@ def get_rf_name(func, package_requirements=None, is_row_processor=False):
9494 """Get a remote function name for testing given a udf."""
9595 # Augment user package requirements with any internal package
9696 # requirements
97- package_requirements = rf_utils ._get_updated_package_requirements (
97+ package_requirements = bff_utils ._get_updated_package_requirements (
9898 package_requirements , is_row_processor
9999 )
100100
101101 # Compute a unique hash representing the user code
102- function_hash = rf_utils ._get_hash (func , package_requirements )
102+ function_hash = bff_utils ._get_hash (func , package_requirements )
103103
104104 return f"bigframes_{ function_hash } "
105105
@@ -117,7 +117,7 @@ def test_remote_function_direct_no_session_param(
117117 def square (x ):
118118 return x * x
119119
120- square = rf .remote_function (
120+ square = bff .remote_function (
121121 int ,
122122 int ,
123123 bigquery_client = bigquery_client ,
@@ -176,7 +176,7 @@ def test_remote_function_direct_no_session_param_location_specified(
176176 def square (x ):
177177 return x * x
178178
179- square = rf .remote_function (
179+ square = bff .remote_function (
180180 int ,
181181 int ,
182182 bigquery_client = bigquery_client ,
@@ -235,7 +235,7 @@ def square(x):
235235 ValueError ,
236236 match = re .escape ("The location does not match BigQuery connection location:" ),
237237 ):
238- rf .remote_function (
238+ bff .remote_function (
239239 int ,
240240 int ,
241241 bigquery_client = bigquery_client ,
@@ -263,7 +263,7 @@ def test_remote_function_direct_no_session_param_location_project_specified(
263263 def square (x ):
264264 return x * x
265265
266- square = rf .remote_function (
266+ square = bff .remote_function (
267267 int ,
268268 int ,
269269 bigquery_client = bigquery_client ,
@@ -324,7 +324,7 @@ def square(x):
324324 "The project_id does not match BigQuery connection gcp_project_id:"
325325 ),
326326 ):
327- rf .remote_function (
327+ bff .remote_function (
328328 int ,
329329 int ,
330330 bigquery_client = bigquery_client ,
@@ -346,7 +346,7 @@ def test_remote_function_direct_session_param(
346346 def square (x ):
347347 return x * x
348348
349- square = rf .remote_function (
349+ square = bff .remote_function (
350350 int ,
351351 int ,
352352 session = session_with_bq_connection ,
@@ -636,7 +636,7 @@ def add_one(x):
636636def test_read_gbq_function_detects_invalid_function (session , dataset_id ):
637637 dataset_ref = bigquery .DatasetReference .from_string (dataset_id )
638638 with pytest .raises (ValueError ) as e :
639- rf .read_gbq_function (
639+ bff .read_gbq_function (
640640 str (dataset_ref .routine ("not_a_function" )),
641641 session = session ,
642642 )
@@ -658,7 +658,7 @@ def test_read_gbq_function_like_original(
658658 def square1 (x ):
659659 return x * x
660660
661- square1 = rf .remote_function (
661+ square1 = bff .remote_function (
662662 [int ],
663663 int ,
664664 bigquery_client = bigquery_client ,
@@ -674,7 +674,7 @@ def square1(x):
674674 # Function should still work normally.
675675 assert square1 (2 ) == 4
676676
677- square2 = rf .read_gbq_function (
677+ square2 = bff .read_gbq_function (
678678 function_name = square1 .bigframes_remote_function , # type: ignore
679679 session = session ,
680680 )
@@ -745,7 +745,7 @@ def test_read_gbq_function_reads_udfs(session, bigquery_client, dataset_id):
745745 for routine in (sql_routine , js_routine ):
746746 # Create the routine in BigQuery and read it back using read_gbq_function.
747747 bigquery_client .create_routine (routine , exists_ok = True )
748- square = rf .read_gbq_function (
748+ square = bff .read_gbq_function (
749749 str (routine .reference ),
750750 session = session ,
751751 )
@@ -757,7 +757,7 @@ def test_read_gbq_function_reads_udfs(session, bigquery_client, dataset_id):
757757
758758 src = {"x" : [- 5 , - 4 , - 3 , - 2 , - 1 , 0 , 1 , 2 , 3 , 4 , 5 ]}
759759
760- routine_ref_str = rf_utils .routine_ref_to_string_for_query (routine .reference )
760+ routine_ref_str = bff_utils .routine_ref_to_string_for_query (routine .reference )
761761 direct_sql = " UNION ALL " .join (
762762 [f"SELECT { x } AS x, { routine_ref_str } ({ x } ) AS y" for x in src ["x" ]]
763763 )
@@ -818,25 +818,25 @@ def test_read_gbq_function_requires_explicit_types(
818818 bigquery_client .create_routine (only_arg_type_specified , exists_ok = True )
819819 bigquery_client .create_routine (neither_type_specified , exists_ok = True )
820820
821- rf .read_gbq_function (
821+ bff .read_gbq_function (
822822 str (both_types_specified .reference ),
823823 session = session ,
824824 )
825825 with pytest .warns (
826826 bigframes .exceptions .UnknownDataTypeWarning ,
827827 match = "missing input data types.*assume default data type" ,
828828 ):
829- rf .read_gbq_function (
829+ bff .read_gbq_function (
830830 str (only_return_type_specified .reference ),
831831 session = session ,
832832 )
833833 with pytest .raises (ValueError ):
834- rf .read_gbq_function (
834+ bff .read_gbq_function (
835835 str (only_arg_type_specified .reference ),
836836 session = session ,
837837 )
838838 with pytest .raises (ValueError ):
839- rf .read_gbq_function (
839+ bff .read_gbq_function (
840840 str (neither_type_specified .reference ),
841841 session = session ,
842842 )
@@ -878,13 +878,13 @@ def test_read_gbq_function_respects_python_output_type(
878878 body = "TO_JSON_STRING([x, x+1, x+2])" ,
879879 arguments = [arg ],
880880 return_type = bigquery .StandardSqlDataType (bigquery .StandardSqlTypeNames .STRING ),
881- description = rf_utils .get_bigframes_metadata (python_output_type = array_type ),
881+ description = bff_utils .get_bigframes_metadata (python_output_type = array_type ),
882882 type_ = bigquery .RoutineType .SCALAR_FUNCTION ,
883883 )
884884
885885 # Create the routine in BigQuery and read it back using read_gbq_function.
886886 bigquery_client .create_routine (sql_routine , exists_ok = True )
887- func = rf .read_gbq_function (str (sql_routine .reference ), session = session )
887+ func = bff .read_gbq_function (str (sql_routine .reference ), session = session )
888888
889889 # test that the function works as expected
890890 s = bigframes .series .Series ([1 , 10 , 100 ])
@@ -920,7 +920,7 @@ def test_read_gbq_function_supports_python_output_type_only_for_string_outputs(
920920 body = "x+1" ,
921921 arguments = [arg ],
922922 return_type = bigquery .StandardSqlDataType (bigquery .StandardSqlTypeNames .INT64 ),
923- description = rf_utils .get_bigframes_metadata (python_output_type = array_type ),
923+ description = bff_utils .get_bigframes_metadata (python_output_type = array_type ),
924924 type_ = bigquery .RoutineType .SCALAR_FUNCTION ,
925925 )
926926
@@ -933,7 +933,7 @@ def test_read_gbq_function_supports_python_output_type_only_for_string_outputs(
933933 TypeError ,
934934 match = "An explicit output_type should be provided only for a BigQuery function with STRING output." ,
935935 ):
936- rf .read_gbq_function (str (sql_routine .reference ), session = session )
936+ bff .read_gbq_function (str (sql_routine .reference ), session = session )
937937
938938
939939@pytest .mark .parametrize (
@@ -959,13 +959,13 @@ def test_read_gbq_function_supported_python_output_type(
959959 body = "CAST(x AS STRING)" ,
960960 arguments = [arg ],
961961 return_type = bigquery .StandardSqlDataType (bigquery .StandardSqlTypeNames .STRING ),
962- description = rf_utils .get_bigframes_metadata (python_output_type = array_type ),
962+ description = bff_utils .get_bigframes_metadata (python_output_type = array_type ),
963963 type_ = bigquery .RoutineType .SCALAR_FUNCTION ,
964964 )
965965
966966 # Create the routine in BigQuery and read it back using read_gbq_function.
967967 bigquery_client .create_routine (sql_routine , exists_ok = True )
968- rf .read_gbq_function (str (sql_routine .reference ), session = session )
968+ bff .read_gbq_function (str (sql_routine .reference ), session = session )
969969
970970
971971@pytest .mark .flaky (retries = 2 , delay = 120 )
0 commit comments