File tree Expand file tree Collapse file tree 2 files changed +6
-18
lines changed
Expand file tree Collapse file tree 2 files changed +6
-18
lines changed Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515
16- def main (client , table_id ):
16+ def load_table_dataframe (client , table_id ):
1717 # [START bigquery_load_table_dataframe]
1818 from google .cloud import bigquery
1919 import pandas
@@ -38,7 +38,7 @@ def main(client, table_id):
3838 # table. The schema is used to assist in data type definitions.
3939 schema = [
4040 # Specify the type of columns whose type cannot be auto-detected. For
41- # example the "title" column uses pandas dtype "object", so it's
41+ # example the "title" column uses pandas dtype "object", so its
4242 # data type is ambiguous.
4343 bigquery .SchemaField ("title" , bigquery .enums .SqlTypeNames .STRING ),
4444 # Indexes are written if included in the schema by name.
@@ -60,4 +60,4 @@ def main(client, table_id):
6060 import sys
6161 from google .cloud import bigquery
6262
63- main (bigquery .Client (), sys .argv [1 ])
63+ load_table_dataframe (bigquery .Client (), sys .argv [1 ])
Original file line number Diff line number Diff line change 1818
1919
2020pytest .importorskip ("pandas" )
21+ pytest .importorskip ("pyarrow" )
2122
2223
23- @pytest .mark .parametrize ("parquet_engine" , ["pyarrow" , "fastparquet" ])
24- def test_main ():
25- if parquet_engine == "pyarrow" and pyarrow is None :
26- pytest .skip ("Requires `pyarrow`" )
27- if parquet_engine == "fastparquet" and fastparquet is None :
28- pytest .skip ("Requires `fastparquet`" )
29-
30- pandas .set_option ("io.parquet.engine" , parquet_engine )
31-
32- dataset_id = "load_table_from_dataframe_{}" .format (_millis ())
33- dataset = bigquery .Dataset (client .dataset (dataset_id ))
34- client .create_dataset (dataset )
35- to_delete .append (dataset )
36-
37- load_table_dataframe .main ()
24+ def test_load_table_dataframe (client , random_table_id ):
25+ load_table_dataframe .load_table_dataframe (client , random_table_id )
3826
3927 column_names = [field .name for field in table .schema ]
4028 assert sorted (column_names ) == ["release_year" , "title" , "wikidata_id" ]
You can’t perform that action at this time.
0 commit comments