From e475e0349937a205d7cd2f97dfc36a15d30550d1 Mon Sep 17 00:00:00 2001 From: Nissan Karki Date: Fri, 21 Jul 2023 15:58:46 +0200 Subject: [PATCH 1/3] Added an error message with column name when Series to pyarrow conversion fails. Allows for easier debugging. --- google/cloud/bigquery/_pandas_helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/google/cloud/bigquery/_pandas_helpers.py b/google/cloud/bigquery/_pandas_helpers.py index a14dbec9b..b8f71890d 100644 --- a/google/cloud/bigquery/_pandas_helpers.py +++ b/google/cloud/bigquery/_pandas_helpers.py @@ -377,7 +377,11 @@ def bq_to_arrow_array(series, bq_field): return pyarrow.ListArray.from_pandas(series, type=arrow_type) if field_type_upper in schema._STRUCT_TYPES: return pyarrow.StructArray.from_pandas(series, type=arrow_type) - return pyarrow.Array.from_pandas(series, type=arrow_type) + try: + return pyarrow.Array.from_pandas(series, type=arrow_type) + except Exception as e: + _LOGGER.error(f'Error converting Pandas column "{series.name}" to pyarrow Array') + raise e def get_column_or_index(dataframe, name): From 64b1041a2039bc5cb2d01ccb186911655b9486ad Mon Sep 17 00:00:00 2001 From: Nissan Karki Date: Fri, 21 Jul 2023 15:58:46 +0200 Subject: [PATCH 2/3] fix: Added an error message with column name when Series to pyarrow conversion fails. --- google/cloud/bigquery/_pandas_helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/google/cloud/bigquery/_pandas_helpers.py b/google/cloud/bigquery/_pandas_helpers.py index a14dbec9b..b8f71890d 100644 --- a/google/cloud/bigquery/_pandas_helpers.py +++ b/google/cloud/bigquery/_pandas_helpers.py @@ -377,7 +377,11 @@ def bq_to_arrow_array(series, bq_field): return pyarrow.ListArray.from_pandas(series, type=arrow_type) if field_type_upper in schema._STRUCT_TYPES: return pyarrow.StructArray.from_pandas(series, type=arrow_type) - return pyarrow.Array.from_pandas(series, type=arrow_type) + try: + return pyarrow.Array.from_pandas(series, type=arrow_type) + except Exception as e: + _LOGGER.error(f'Error converting Pandas column "{series.name}" to pyarrow Array') + raise e def get_column_or_index(dataframe, name): From 02e797681f1b9fdc5489f443058c8190be441a62 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 28 Feb 2024 20:54:19 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- google/cloud/bigquery/_pandas_helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/google/cloud/bigquery/_pandas_helpers.py b/google/cloud/bigquery/_pandas_helpers.py index 177230263..e76b4d0a8 100644 --- a/google/cloud/bigquery/_pandas_helpers.py +++ b/google/cloud/bigquery/_pandas_helpers.py @@ -309,7 +309,9 @@ def bq_to_arrow_array(series, bq_field): try: return pyarrow.Array.from_pandas(series, type=arrow_type) except Exception as e: - _LOGGER.error(f'Error converting Pandas column "{series.name}" to pyarrow Array') + _LOGGER.error( + f'Error converting Pandas column "{series.name}" to pyarrow Array' + ) raise e