@@ -537,19 +537,20 @@ def add_one(x):
537537
538538
539539@pytest .mark .flaky (retries = 2 , delay = 120 )
540- def test_read_gbq_function_detects_invalid_function (bigquery_client , dataset_id ):
540+ def test_read_gbq_function_detects_invalid_function (session , dataset_id ):
541541 dataset_ref = bigquery .DatasetReference .from_string (dataset_id )
542542 with pytest .raises (ValueError ) as e :
543543 rf .read_gbq_function (
544544 str (dataset_ref .routine ("not_a_function" )),
545- bigquery_client = bigquery_client ,
545+ session = session ,
546546 )
547547
548548 assert "Unknown function" in str (e .value )
549549
550550
551551@pytest .mark .flaky (retries = 2 , delay = 120 )
552552def test_read_gbq_function_like_original (
553+ session ,
553554 bigquery_client ,
554555 bigqueryconnection_client ,
555556 cloudfunctions_client ,
@@ -577,7 +578,7 @@ def square1(x):
577578
578579 square2 = rf .read_gbq_function (
579580 function_name = square1 .bigframes_remote_function ,
580- bigquery_client = bigquery_client ,
581+ session = session ,
581582 )
582583
583584 # The newly-created function (square1) should have a remote function AND a
@@ -607,7 +608,14 @@ def square1(x):
607608
608609
609610@pytest .mark .flaky (retries = 2 , delay = 120 )
610- def test_read_gbq_function_reads_udfs (bigquery_client , dataset_id ):
611+ def test_read_gbq_function_runs_existing_udf (session , bigquery_client , dataset_id ):
612+ func = session .read_gbq_function ("bqutil.fn.cw_lower_case_ascii_only" )
613+ got = func ("AURÉLIE" )
614+ assert got == "aurÉlie"
615+
616+
617+ @pytest .mark .flaky (retries = 2 , delay = 120 )
618+ def test_read_gbq_function_reads_udfs (session , bigquery_client , dataset_id ):
611619 dataset_ref = bigquery .DatasetReference .from_string (dataset_id )
612620 arg = bigquery .RoutineArgument (
613621 name = "x" ,
@@ -633,7 +641,8 @@ def test_read_gbq_function_reads_udfs(bigquery_client, dataset_id):
633641 # Create the routine in BigQuery and read it back using read_gbq_function.
634642 bigquery_client .create_routine (routine , exists_ok = True )
635643 square = rf .read_gbq_function (
636- str (routine .reference ), bigquery_client = bigquery_client
644+ str (routine .reference ),
645+ session = session ,
637646 )
638647
639648 # It should point to the named routine and yield the expected results.
@@ -658,7 +667,9 @@ def test_read_gbq_function_reads_udfs(bigquery_client, dataset_id):
658667
659668
660669@pytest .mark .flaky (retries = 2 , delay = 120 )
661- def test_read_gbq_function_enforces_explicit_types (bigquery_client , dataset_id ):
670+ def test_read_gbq_function_enforces_explicit_types (
671+ session , bigquery_client , dataset_id
672+ ):
662673 dataset_ref = bigquery .DatasetReference .from_string (dataset_id )
663674 typed_arg = bigquery .RoutineArgument (
664675 name = "x" ,
@@ -702,18 +713,22 @@ def test_read_gbq_function_enforces_explicit_types(bigquery_client, dataset_id):
702713 bigquery_client .create_routine (neither_type_specified , exists_ok = True )
703714
704715 rf .read_gbq_function (
705- str (both_types_specified .reference ), bigquery_client = bigquery_client
716+ str (both_types_specified .reference ),
717+ session = session ,
706718 )
707719 rf .read_gbq_function (
708- str (only_return_type_specified .reference ), bigquery_client = bigquery_client
720+ str (only_return_type_specified .reference ),
721+ session = session ,
709722 )
710723 with pytest .raises (ValueError ):
711724 rf .read_gbq_function (
712- str (only_arg_type_specified .reference ), bigquery_client = bigquery_client
725+ str (only_arg_type_specified .reference ),
726+ session = session ,
713727 )
714728 with pytest .raises (ValueError ):
715729 rf .read_gbq_function (
716- str (neither_type_specified .reference ), bigquery_client = bigquery_client
730+ str (neither_type_specified .reference ),
731+ session = session ,
717732 )
718733
719734
0 commit comments