Skip to content

Commit

Permalink
Fix pyarrow Table type hinting in cursor.py (#1835)
Browse files Browse the repository at this point in the history
* fix pyarrow Table type
* reorder imports within TYPE_CHECKING
* Use existing import check and improve warning
* remove import
  • Loading branch information
thomasaarholt authored Jan 8, 2024
1 parent 2a335be commit ca8a580
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
- Cleanup some C++ code warnings and performance issues.
- Added support for Python 3.12
- Make local testing more robust against implicit assumptions.
- Fixed PyArrow Table type hinting

- v3.6.0(December 09,2023)

Expand Down
14 changes: 9 additions & 5 deletions src/snowflake/connector/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@

if TYPE_CHECKING: # pragma: no cover
from pandas import DataFrame
from pyarrow import Table

from .connection import SnowflakeConnection
from .file_transfer_agent import SnowflakeProgressPercentage
Expand All @@ -81,11 +82,14 @@

logger = getLogger(__name__)

if installed_pandas:
from pyarrow import Table
else:
logger.debug("Failed to import pyarrow. Cannot use pandas fetch API")
Table = None

if not installed_pandas:
logger.debug(
"Failed to import pyarrow or pandas. Cannot use pandas fetch API. Please "
"install snowflake-connector-python with the `pandas` extra to use these "
"features."
)


try:
from .nanoarrow_arrow_iterator import PyArrowIterator # NOQA
Expand Down

0 comments on commit ca8a580

Please sign in to comment.