Skip to content

Commit a5276cf

Browse files
tonyparthenioujreback
authored andcommitted
ENH: Add ability to create datasets using the gbq module pandas-dev#11121
CLN: Make new API objects in the gbq module private and remove from documentation pandas-dev#11121 BUG: Handle GBQ datasets being empty and fix test_list_table test pandas-dev#11121 CLN: Deprecated generate_bq_schema in gbq module in favor of generate_schema pandas-dev#11121
1 parent c0410fd commit a5276cf

File tree

5 files changed

+394
-255
lines changed

5 files changed

+394
-255
lines changed

doc/source/api.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ Google BigQuery
110110

111111
read_gbq
112112
to_gbq
113-
generate_bq_schema
114-
create_table
115-
delete_table
116-
table_exists
113+
117114

118115
.. currentmodule:: pandas
119116

doc/source/io.rst

+7-43
Original file line numberDiff line numberDiff line change
@@ -4005,14 +4005,10 @@ The key functions are:
40054005
.. currentmodule:: pandas.io.gbq
40064006

40074007
.. autosummary::
4008-
:toctree: generated/
4008+
:toctree: generated/
40094009

4010-
read_gbq
4011-
to_gbq
4012-
generate_bq_schema
4013-
create_table
4014-
delete_table
4015-
table_exists
4010+
read_gbq
4011+
to_gbq
40164012

40174013
.. currentmodule:: pandas
40184014

@@ -4078,8 +4074,7 @@ Assume we want to write a DataFrame ``df`` into a BigQuery table using :func:`~p
40784074
40794075
.. note::
40804076

4081-
If the destination table does not exist, a new table will be created. The
4082-
destination dataset id must already exist in order for a new table to be created.
4077+
The destination table and destination dataset will automatically be created if they do not already exist.
40834078

40844079
The ``if_exists`` argument can be used to dictate whether to ``'fail'``, ``'replace'``
40854080
or ``'append'`` if the destination table already exists. The default value is ``'fail'``.
@@ -4146,19 +4141,13 @@ For example:
41464141
often as the service seems to be changing and evolving. BiqQuery is best for analyzing large
41474142
sets of data quickly, but it is not a direct replacement for a transactional database.
41484143

4149-
41504144
Creating BigQuery Tables
41514145
''''''''''''''''''''''''
41524146

4153-
As of 0.17.0, the gbq module has a function :func:`~pandas.io.gbq.create_table` which allows users
4154-
to create a table in BigQuery. The only requirement is that the dataset must already exist.
4155-
The schema may be generated from a pandas DataFrame using the :func:`~pandas.io.gbq.generate_bq_schema` function below.
4156-
4157-
For example:
4158-
4159-
.. code-block:: python
4147+
.. warning::
41604148

4161-
gbq.create_table('my_dataset.my_table', schema, projectid)
4149+
As of 0.17, the function :func:`~pandas.io.gbq.generate_bq_schema` has been deprecated and will be
4150+
removed in a future version.
41624151

41634152
As of 0.15.2, the gbq module has a function :func:`~pandas.io.gbq.generate_bq_schema` which will
41644153
produce the dictionary representation schema of the specified pandas DataFrame.
@@ -4174,31 +4163,6 @@ produce the dictionary representation schema of the specified pandas DataFrame.
41744163
{'name': 'my_int64', 'type': 'INTEGER'},
41754164
{'name': 'my_string', 'type': 'STRING'}]}
41764165
4177-
Deleting BigQuery Tables
4178-
''''''''''''''''''''''''
4179-
4180-
As of 0.17.0, the gbq module has a function :func:`~pandas.io.gbq.delete_table` which allows users to delete a table
4181-
in Google BigQuery.
4182-
4183-
For example:
4184-
4185-
.. code-block:: python
4186-
4187-
gbq.delete_table('my_dataset.my_table', projectid)
4188-
4189-
The following function can be used to check whether a table exists prior to calling ``table_exists``:
4190-
4191-
:func:`~pandas.io.gbq.table_exists`.
4192-
4193-
The return value will be of type boolean.
4194-
4195-
For example:
4196-
4197-
.. code-block:: python
4198-
4199-
In [12]: gbq.table_exists('my_dataset.my_table', projectid)
4200-
Out[12]: True
4201-
42024166
.. note::
42034167

42044168
If you delete and re-create a BigQuery table with the same name, but different table schema,

doc/source/whatsnew/v0.17.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ has been changed to make this keyword unnecessary - the change is shown below.
328328
Google BigQuery Enhancements
329329
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
330330
- Added ability to automatically create a table using the :func:`pandas.io.gbq.to_gbq` function if destination table does not exist. (:issue:`8325`).
331+
- Added ability to automatically create a dataset using the :func:`pandas.io.gbq.to_gbq` function if destination dataset does not exist. (:issue:`11121`).
331332
- Added ability to replace an existing table and schema when calling the :func:`pandas.io.gbq.to_gbq` function via the ``if_exists`` argument. See the :ref:`docs <io.bigquery>` for more details (:issue:`8325`).
332-
- Added the following functions to the gbq module: :func:`pandas.io.gbq.table_exists`, :func:`pandas.io.gbq.create_table`, and :func:`pandas.io.gbq.delete_table`. See the :ref:`docs <io.bigquery>` for more details (:issue:`8325`).
333333
- ``InvalidColumnOrder`` and ``InvalidPageToken`` in the gbq module will raise ``ValueError`` instead of ``IOError``.
334334

335335
.. _whatsnew_0170.enhancements.other:

0 commit comments

Comments
 (0)