8000 fix: Enhance type error messages for bigframes functions by jialuoo · Pull Request #1958 · googleapis/python-bigquery-dataframes · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bigframes/functions/function_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def __init__(self, type_, supported_types):
self.type = type_
self.supported_types = supported_types
super().__init__(
f"'{type_}' is not one of the supported types {supported_types}"
f"'{type_}' must be one of the supported types ({supported_types}) "
"or a list of one of those types."
)


Expand Down
27 changes: 27 additions & 0 deletions tests/system/small/functions/test_remote_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import inspect
import re
import textwrap
from typing import Sequence

import bigframes_vendored.constants as constants
import google.api_core.exceptions
Expand Down Expand Up @@ -1642,3 +1643,29 @@ def processor(x: int, y: int, z: float, w: str) -> str:
df = scalars_df_index[["int64_col", "int64_too", "float64_col", "string_col"]]
df1 = df.assign(combined=df.apply(processor, axis=1))
repr(df1)


@pytest.mark.flaky(retries=2, delay=120)
def test_remote_function_unsupported_type(
session,
dataset_id_permanent,
bq_cf_connection,
):
# Remote functions do not support tuple return types.
def func_tuple(x):
return (x, x, x)

with pytest.raises(
ValueError,
match=r"'typing\.Sequence\[int\]' must be one of the supported types",
):
bff.remote_function(
input_types=int,
output_type=Sequence[int],
session=session,
dataset=dataset_id_permanent,
bigquery_connection=bq_cf_connection,
reuse=True,
name=get_function_name(func_tuple),
cloud_function_service_account="default",
)(func_tuple)
0