File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
tests/system/large/functions Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 25
25
import typing
26
26
from typing import (
27
27
Any ,
28
+ Callable ,
28
29
cast ,
29
30
Iterable ,
30
31
List ,
@@ -2339,7 +2340,7 @@ def _throw_if_index_contains_duplicates(
2339
2340
2340
2341
def map (
2341
2342
self ,
2342
- arg : typing .Union [Mapping , Series ],
2343
+ arg : typing .Union [Mapping , Series , Callable ],
2343
2344
na_action : Optional [str ] = None ,
2344
2345
* ,
2345
2346
verify_integrity : bool = False ,
@@ -2361,6 +2362,7 @@ def map(
2361
2362
)
2362
2363
map_df = map_df .set_index ("keys" )
2363
2364
elif callable (arg ):
2365
+ # This is for remote function and managed funtion.
2364
2366
return self .apply (arg )
2365
2367
else :
2366
2368
# Mirroring pandas, call the uncallable object
Original file line number Diff line number Diff line change @@ -1245,7 +1245,7 @@ def the_sum(s):
1245
1245
cleanup_function_assets (the_sum_mf , session .bqclient , ignore_failures = False )
1246
1246
1247
1247
1248
- def test_managed_function_series_where_mask (session , dataset_id , scalars_dfs ):
1248
+ def test_managed_function_series_where_mask_map (session , dataset_id , scalars_dfs ):
1249
1249
try :
1250
1250
1251
1251
# The return type has to be bool type for callable where condition.
@@ -1286,6 +1286,13 @@ def _is_positive(s):
1286
1286
# Ignore any dtype difference.
1287
1287
pandas .testing .assert_series_equal (bf_result , pd_result , check_dtype = False )
1288
1288
1289
+ # Test series.map method.
1290
+ bf_result = bf_int64_filtered .map (is_positive_mf ).to_pandas ()
1291
+ pd_result = pd_int64_filtered .map (_is_positive )
1292
+
1293
+ # Ignore any dtype difference.
1294
+ pandas .testing .assert_series_equal (bf_result , pd_result , check_dtype = False )
1295
+
1289
1296
finally :
1290
1297
# Clean up the gcp assets created for the managed function.
1291
1298
cleanup_function_assets (is_positive_mf , session .bqclient , ignore_failures = False )
You can’t perform that action at this time.
0 commit comments