File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
- from typing import TYPE_CHECKING
3
+ from typing import (
4
+ TYPE_CHECKING ,
5
+ Literal ,
6
+ )
4
7
5
8
import numpy as np
6
9
15
18
if TYPE_CHECKING :
16
19
from collections .abc import Callable
17
20
21
+ import pyarrow
22
+
18
23
from pandas ._typing import DtypeBackend
19
24
20
25
@@ -52,8 +57,8 @@ def _arrow_string_types_mapper() -> Callable:
52
57
53
58
54
59
def arrow_table_to_pandas (
55
- table ,
56
- dtype_backend : DtypeBackend | lib .NoDefault = lib .no_default ,
60
+ table : pyarrow . Table ,
61
+ dtype_backend : DtypeBackend | Literal [ "numpy" ] | lib .NoDefault = lib .no_default ,
57
62
null_to_int64 : bool = False ,
58
63
) -> pd .DataFrame :
59
64
pa = import_optional_dependency ("pyarrow" )
@@ -70,7 +75,7 @@ def arrow_table_to_pandas(
70
75
types_mapper = pd .ArrowDtype
71
76
elif using_string_dtype ():
72
77
types_mapper = _arrow_string_types_mapper ()
73
- elif dtype_backend is lib .no_default :
78
+ elif dtype_backend is lib .no_default or dtype_backend == "numpy" :
74
79
types_mapper = None
75
80
else :
76
81
raise NotImplementedError
Original file line number Diff line number Diff line change @@ -2210,9 +2210,6 @@ def read_table(
2210
2210
with self .con .cursor () as cur :
2211
2211
cur .execute (stmt )
2212
2212
pa_table = cur .fetch_arrow_table ()
2213
- dtype_backend = (
2214
- lib .no_default if dtype_backend == "numpy" else dtype_backend
2215
- )
2216
2213
df = arrow_table_to_pandas (pa_table , dtype_backend = dtype_backend )
2217
2214
2218
2215
return _wrap_result_adbc (
@@ -2284,9 +2281,6 @@ def read_query(
2284
2281
with self .con .cursor () as cur :
2285
2282
cur .execute (sql )
2286
2283
pa_table = cur .fetch_arrow_table ()
2287
- dtype_backend = (
2288
- lib .no_default if dtype_backend == "numpy" else dtype_backend
2289
- )
2290
2284
df = arrow_table_to_pandas (pa_table , dtype_backend = dtype_backend )
2291
2285
2292
2286
return _wrap_result_adbc (
You can’t perform that action at this time.
0 commit comments