1
1
""" Google BigQuery support """
2
+ from typing import TYPE_CHECKING , Any , Dict , List , Optional , Union
3
+
2
4
from pandas .compat ._optional import import_optional_dependency
3
5
6
+ if TYPE_CHECKING :
7
+ from pandas import DataFrame
8
+
4
9
5
10
def _try_import ():
6
11
# since pandas is a dependency of pandas-gbq
@@ -14,21 +19,21 @@ def _try_import():
14
19
15
20
16
21
def read_gbq (
17
- query ,
18
- project_id = None ,
19
- index_col = None ,
20
- col_order = None ,
21
- reauth = False ,
22
- auth_local_webserver = False ,
23
- dialect = None ,
24
- location = None ,
25
- configuration = None ,
22
+ query : str ,
23
+ project_id : Optional [ str ] = None ,
24
+ index_col : Optional [ str ] = None ,
25
+ col_order : Optional [ List [ str ]] = None ,
26
+ reauth : bool = False ,
27
+ auth_local_webserver : bool = False ,
28
+ dialect : Optional [ str ] = None ,
29
+ location : Optional [ str ] = None ,
30
+ configuration : Optional [ Dict [ str , Any ]] = None ,
26
31
credentials = None ,
27
- use_bqstorage_api = None ,
32
+ use_bqstorage_api : Optional [ bool ] = None ,
28
33
private_key = None ,
29
34
verbose = None ,
30
- progress_bar_type = None ,
31
- ):
35
+ progress_bar_type : Optional [ str ] = None ,
36
+ ) -> "DataFrame" :
32
37
"""
33
38
Load data from Google BigQuery.
34
39
@@ -157,7 +162,7 @@ def read_gbq(
157
162
"""
158
163
pandas_gbq = _try_import ()
159
164
160
- kwargs = {}
165
+ kwargs : Dict [ str , Union [ str , bool ]] = {}
161
166
162
167
# START: new kwargs. Don't populate unless explicitly set.
163
168
if use_bqstorage_api is not None :
@@ -183,20 +188,20 @@ def read_gbq(
183
188
184
189
185
190
def to_gbq (
186
- dataframe ,
187
- destination_table ,
188
- project_id = None ,
189
- chunksize = None ,
190
- reauth = False ,
191
- if_exists = "fail" ,
192
- auth_local_webserver = False ,
193
- table_schema = None ,
194
- location = None ,
195
- progress_bar = True ,
191
+ dataframe : "DataFrame" ,
192
+ destination_table : str ,
193
+ project_id : Optional [ str ] = None ,
194
+ chunksize : Optional [ int ] = None ,
195
+ reauth : bool = False ,
196
+ if_exists : str = "fail" ,
197
+ auth_local_webserver : bool = False ,
198
+ table_schema : Optional [ List [ Dict [ str , str ]]] = None ,
199
+ location : Optional [ str ] = None ,
200
+ progress_bar : bool = True ,
196
201
credentials = None ,
197
202
verbose = None ,
198
203
private_key = None ,
199
- ):
204
+ ) -> None :
200
205
pandas_gbq = _try_import ()
201
206
pandas_gbq .to_gbq (
202
207
dataframe ,
0 commit comments