From 2e82b89c9ec54e6b136f1ab43d8c135e2ac850ed Mon Sep 17 00:00:00 2001 From: Ashley Xu Date: Tue, 7 Nov 2023 23:50:42 +0000 Subject: [PATCH 1/2] docs: add code samples for read_gbq_function using community UDFs --- bigframes/session/__init__.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/bigframes/session/__init__.py b/bigframes/session/__init__.py index b49e2469a9..0a4a60327d 100644 --- a/bigframes/session/__init__.py +++ b/bigframes/session/__init__.py @@ -1456,15 +1456,37 @@ def read_gbq_function( The return type of the function must be explicitly specified in the function's original definition even if not otherwise required. + BigQuery UDFs has many public functions under the ``bqutil`` project on publicly shared datasets + (See: https://github.com/GoogleCloudPlatform/bigquery-utils/tree/master/udfs#using-the-udfs). + You can checkout Community UDFs to use community-contributed functions. + (See: https://github.com/GoogleCloudPlatform/bigquery-utils/tree/master/udfs/community#community-udfs). + **Examples:** + Using the ``cw_lower_case_ascii_only`` function from Community UDFs. + (https://github.com/GoogleCloudPlatform/bigquery-utils/blob/master/udfs/community/cw_lower_case_ascii_only.sqlx) + >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None - >>> function_name = "bqutil.fn.cw_lower_case_ascii_only" - >>> func = bpd.read_gbq_function(function_name=function_name) - >>> func.bigframes_remote_function - 'bqutil.fn.cw_lower_case_ascii_only' + >>> df = bpd.DataFrame({'id': [1, 2, 3], 'name': ['AURÉLIE', 'CÉLESTINE', 'DAPHNÉ']}) + >>> df + id name + 0 1 AURÉLIE + 1 2 CÉLESTINE + 2 3 DAPHNÉ + + [3 rows x 2 columns] + + >>> func = bpd.read_gbq_function("bqutil.fn.cw_lower_case_ascii_only") + >>> df1 = df.assign(new_name=df['name'].apply(func)) + >>> df1 + id name new_name + 0 1 AURÉLIE aurÉlie + 1 2 CÉLESTINE cÉlestine + 2 3 DAPHNÉ daphnÉ + + [3 rows x 3 columns] Args: function_name (str): From 4a065cbf1f67dd68bec5bbddf70f1f964666ef27 Mon Sep 17 00:00:00 2001 From: Ashley Xu Date: Mon, 13 Nov 2023 17:05:16 +0000 Subject: [PATCH 2/2] fix: address comments --- bigframes/session/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bigframes/session/__init__.py b/bigframes/session/__init__.py index 0a4a60327d..84aa5c6914 100644 --- a/bigframes/session/__init__.py +++ b/bigframes/session/__init__.py @@ -1456,14 +1456,14 @@ def read_gbq_function( The return type of the function must be explicitly specified in the function's original definition even if not otherwise required. - BigQuery UDFs has many public functions under the ``bqutil`` project on publicly shared datasets + BigQuery Utils provides many public functions under the ``bqutil`` project on Google Cloud Platform project (See: https://github.com/GoogleCloudPlatform/bigquery-utils/tree/master/udfs#using-the-udfs). You can checkout Community UDFs to use community-contributed functions. (See: https://github.com/GoogleCloudPlatform/bigquery-utils/tree/master/udfs/community#community-udfs). **Examples:** - Using the ``cw_lower_case_ascii_only`` function from Community UDFs. + Use the ``cw_lower_case_ascii_only`` function from Community UDFs. (https://github.com/GoogleCloudPlatform/bigquery-utils/blob/master/udfs/community/cw_lower_case_ascii_only.sqlx) >>> import bigframes.pandas as bpd