|
32 | 32 | import pandas # type: ignore |
33 | 33 |
|
34 | 34 | pandas_import_exception = None |
35 | | -except ImportError as exc: # pragma: NO COVER |
| 35 | +except ImportError as exc: |
36 | 36 | pandas = None |
37 | 37 | pandas_import_exception = exc |
38 | 38 | else: |
|
44 | 44 | date_dtype_name = db_dtypes.DateDtype.name |
45 | 45 | time_dtype_name = db_dtypes.TimeDtype.name |
46 | 46 | db_dtypes_import_exception = None |
47 | | -except ImportError as exc: # pragma: NO COVER |
| 47 | +except ImportError as exc: |
48 | 48 | db_dtypes = None |
49 | 49 | db_dtypes_import_exception = exc |
50 | 50 | date_dtype_name = time_dtype_name = "" # Use '' rather than None because pytype |
51 | 51 |
|
52 | | -pyarrow = _versions_helpers.PYARROW_VERSIONS.try_import(raise_if_error=True) |
53 | | -from pyarrow import ArrowTypeError # type: ignore # noqa: E402 |
54 | | - |
55 | | -_BIGNUMERIC_SUPPORT = False |
56 | | -if pyarrow is not None: # pragma: NO COVER |
57 | | - _BIGNUMERIC_SUPPORT = True |
| 52 | +pyarrow = _versions_helpers.PYARROW_VERSIONS.try_import() |
58 | 53 |
|
59 | 54 | try: |
60 | 55 | # _BaseGeometry is used to detect shapely objevys in `bq_to_arrow_array` |
61 | 56 | from shapely.geometry.base import BaseGeometry as _BaseGeometry # type: ignore |
62 | | -except ImportError: # pragma: NO COVER |
| 57 | +except ImportError: |
63 | 58 | # No shapely, use NoneType for _BaseGeometry as a placeholder. |
64 | 59 | _BaseGeometry = type(None) |
65 | 60 | else: |
| 61 | + # We don't have any unit test sessions that install shapely but not pandas. |
66 | 62 | if pandas is not None: # pragma: NO COVER |
67 | 63 |
|
68 | 64 | def _to_wkb(): |
@@ -309,10 +305,10 @@ def bq_to_arrow_array(series, bq_field): |
309 | 305 | if field_type_upper in schema._STRUCT_TYPES: |
310 | 306 | return pyarrow.StructArray.from_pandas(series, type=arrow_type) |
311 | 307 | return pyarrow.Array.from_pandas(series, type=arrow_type) |
312 | | - except ArrowTypeError: # pragma: NO COVER |
| 308 | + except pyarrow.ArrowTypeError: |
313 | 309 | msg = f"""Error converting Pandas column with name: "{series.name}" and datatype: "{series.dtype}" to an appropriate pyarrow datatype: Array, ListArray, or StructArray""" |
314 | 310 | _LOGGER.error(msg) |
315 | | - raise ArrowTypeError(msg) |
| 311 | + raise pyarrow.ArrowTypeError(msg) |
316 | 312 |
|
317 | 313 |
|
318 | 314 | def get_column_or_index(dataframe, name): |
|
0 commit comments