Skip to content

Commit ca8a580

Browse files
Fix pyarrow Table type hinting in cursor.py (#1835)
* fix pyarrow Table type * reorder imports within TYPE_CHECKING * Use existing import check and improve warning * remove import
1 parent 2a335be commit ca8a580

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

DESCRIPTION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
1414
- Cleanup some C++ code warnings and performance issues.
1515
- Added support for Python 3.12
1616
- Make local testing more robust against implicit assumptions.
17+
- Fixed PyArrow Table type hinting
1718

1819
- v3.6.0(December 09,2023)
1920

src/snowflake/connector/cursor.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272

7373
if TYPE_CHECKING: # pragma: no cover
7474
from pandas import DataFrame
75+
from pyarrow import Table
7576

7677
from .connection import SnowflakeConnection
7778
from .file_transfer_agent import SnowflakeProgressPercentage
@@ -81,11 +82,14 @@
8182

8283
logger = getLogger(__name__)
8384

84-
if installed_pandas:
85-
from pyarrow import Table
86-
else:
87-
logger.debug("Failed to import pyarrow. Cannot use pandas fetch API")
88-
Table = None
85+
86+
if not installed_pandas:
87+
logger.debug(
88+
"Failed to import pyarrow or pandas. Cannot use pandas fetch API. Please "
89+
"install snowflake-connector-python with the `pandas` extra to use these "
90+
"features."
91+
)
92+
8993

9094
try:
9195
from .nanoarrow_arrow_iterator import PyArrowIterator # NOQA

0 commit comments

Comments
 (0)