@@ -537,19 +537,20 @@ def add_one(x):
537
537
538
538
539
539
@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 ):
541
541
dataset_ref = bigquery .DatasetReference .from_string (dataset_id )
542
542
with pytest .raises (ValueError ) as e :
543
543
rf .read_gbq_function (
544
544
str (dataset_ref .routine ("not_a_function" )),
545
- bigquery_client = bigquery_client ,
545
+ session = session ,
546
546
)
547
547
548
548
assert "Unknown function" in str (e .value )
549
549
550
550
551
551
@pytest .mark .flaky (retries = 2 , delay = 120 )
552
552
def test_read_gbq_function_like_original (
553
+ session ,
553
554
bigquery_client ,
554
555
bigqueryconnection_client ,
555
556
cloudfunctions_client ,
@@ -577,7 +578,7 @@ def square1(x):
577
578
578
579
square2 = rf .read_gbq_function (
579
580
function_name = square1 .bigframes_remote_function ,
580
- bigquery_client = bigquery_client ,
581
+ session = session ,
581
582
)
582
583
583
584
# The newly-created function (square1) should have a remote function AND a
@@ -607,7 +608,14 @@ def square1(x):
607
608
608
609
609
610
@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 ):
611
619
dataset_ref = bigquery .DatasetReference .from_string (dataset_id )
612
620
arg = bigquery .RoutineArgument (
613
621
name = "x" ,
@@ -633,7 +641,8 @@ def test_read_gbq_function_reads_udfs(bigquery_client, dataset_id):
633
641
# Create the routine in BigQuery and read it back using read_gbq_function.
634
642
bigquery_client .create_routine (routine , exists_ok = True )
635
643
square = rf .read_gbq_function (
636
- str (routine .reference ), bigquery_client = bigquery_client
644
+ str (routine .reference ),
645
+ session = session ,
637
646
)
638
647
639
648
# 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):
658
667
659
668
660
669
@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
+ ):
662
673
dataset_ref = bigquery .DatasetReference .from_string (dataset_id )
663
674
typed_arg = bigquery .RoutineArgument (
664
675
name = "x" ,
@@ -702,18 +713,22 @@ def test_read_gbq_function_enforces_explicit_types(bigquery_client, dataset_id):
702
713
bigquery_client .create_routine (neither_type_specified , exists_ok = True )
703
714
704
715
rf .read_gbq_function (
705
- str (both_types_specified .reference ), bigquery_client = bigquery_client
716
+ str (both_types_specified .reference ),
717
+ session = session ,
706
718
)
707
719
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 ,
709
722
)
710
723
with pytest .raises (ValueError ):
711
724
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 ,
713
727
)
714
728
with pytest .raises (ValueError ):
715
729
rf .read_gbq_function (
716
- str (neither_type_specified .reference ), bigquery_client = bigquery_client
730
+ str (neither_type_specified .reference ),
731
+ session = session ,
717
732
)
718
733
719
734
0 commit comments