Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 46c1842

Browse files
authoredMay 28, 2024··
Merge branch 'main' into null-nums
2 parents 483195c + 631532c commit 46c1842

31 files changed

+36
-54
lines changed
 

‎docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
# All configuration values have a default; values that are commented out
2525
# serve to show the default.
2626

27-
import sys
2827
import os
2928
import shlex
29+
import sys
3030

3131
# If extensions (or modules to document with autodoc) are in another directory,
3232
# add these directories to sys.path here. If the directory is relative to the

‎docs/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Note: The canonical version of this documentation can always be found on the
2323
`BigQuery sandbox <https://cloud.google.com/bigquery/docs/sandbox>`__ to
2424
try the service for free.
2525

26-
Also, consider using `BigQuery DataFrames
27-
<https://cloud.google.com/bigquery/docs/bigquery-dataframes-introduction>`__
26+
Also, consider using BigQuery DataFrames
27+
(`bit.ly/bigframes-intro <https://bit.ly/bigframes-intro>`__)
2828
to process large results with pandas compatible APIs with transparent SQL
2929
pushdown to BigQuery engine. This provides an opportunity to save on costs
3030
and improve performance.

‎docs/intro.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Reading data from BigQuery
2727
Use the :func:`pandas_gbq.read_gbq` function to run a BigQuery query and
2828
download the results as a :class:`pandas.DataFrame` object.
2929

30-
.. literalinclude:: samples/snippets/read_gbq_simple.py
30+
.. literalinclude:: ../samples/snippets/read_gbq_simple.py
3131
:language: python
3232
:dedent: 4
3333
:start-after: [START bigquery_pandas_gbq_read_gbq_simple]
@@ -57,7 +57,7 @@ Writing data to BigQuery
5757
Use the :func:`pandas_gbq.to_gbq` function to write a
5858
:class:`pandas.DataFrame` object to a BigQuery table.
5959

60-
.. literalinclude:: samples/snippets/to_gbq_simple.py
60+
.. literalinclude:: ../samples/snippets/to_gbq_simple.py
6161
:language: python
6262
:dedent: 4
6363
:start-after: [START bigquery_pandas_gbq_to_gbq_simple]

‎docs/reading.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Reading Tables
66
Use the :func:`pandas_gbq.read_gbq` function to run a BigQuery query and
77
download the results as a :class:`pandas.DataFrame` object.
88

9-
.. literalinclude:: samples/snippets/read_gbq_simple.py
9+
.. literalinclude:: ../samples/snippets/read_gbq_simple.py
1010
:language: python
1111
:dedent: 4
1212
:start-after: [START bigquery_pandas_gbq_read_gbq_simple]
@@ -37,7 +37,7 @@ The ``dialect`` argument can be used to indicate whether to use
3737
BigQuery's ``'legacy'`` SQL or BigQuery's ``'standard'`` SQL. The
3838
default value is ``'standard'``.
3939

40-
.. literalinclude:: samples/snippets/read_gbq_legacy.py
40+
.. literalinclude:: ../samples/snippets/read_gbq_legacy.py
4141
:language: python
4242
:dedent: 4
4343
:start-after: [START bigquery_pandas_gbq_read_gbq_legacy]

‎docs/samples

-1
This file was deleted.

‎docs/writing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Writing Tables
66
Use the :func:`pandas_gbq.to_gbq` function to write a
77
:class:`pandas.DataFrame` object to a BigQuery table.
88

9-
.. literalinclude:: samples/snippets/to_gbq_simple.py
9+
.. literalinclude:: ../samples/snippets/to_gbq_simple.py
1010
:language: python
1111
:dedent: 4
1212
:start-after: [START bigquery_pandas_gbq_to_gbq_simple]

‎noxfile.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# Generated by synthtool. DO NOT EDIT!
1818

1919
from __future__ import absolute_import
20+
2021
import os
2122
import pathlib
2223
import re

‎owlbot.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# creating clients, not the end user.
5656
"docs/multiprocessing.rst",
5757
"noxfile.py",
58-
"README.rst",
58+
"README.rst",
5959
# exclude .kokoro/build.sh which is customized due to support for conda
6060
".kokoro/build.sh",
6161
],
@@ -66,7 +66,9 @@
6666
# ----------------------------------------------------------------------------
6767

6868
s.replace(
69-
[".github/header-checker-lint.yml"], '"Google LLC"', '"pandas-gbq Authors"',
69+
[".github/header-checker-lint.yml"],
70+
'"Google LLC"',
71+
'"pandas-gbq Authors"',
7072
)
7173

7274
# ----------------------------------------------------------------------------
@@ -79,6 +81,6 @@
7981
# Final cleanup
8082
# ----------------------------------------------------------------------------
8183

82-
s.shell.run(["nox", "-s", "blacken"], hide_output=False)
84+
s.shell.run(["nox", "-s", "format"], hide_output=False)
8385
for noxfile in REPO_ROOT.glob("samples/**/noxfile.py"):
84-
s.shell.run(["nox", "-s", "blacken"], cwd=noxfile.parent, hide_output=False)
86+
s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False)

‎pandas_gbq/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# Use of this source code is governed by a BSD-style
33
# license that can be found in the LICENSE file.
44

5-
from .gbq import to_gbq, read_gbq, Context, context # noqa
6-
75
from pandas_gbq import version as pandas_gbq_version
86

7+
from .gbq import Context, context, read_gbq, to_gbq # noqa
8+
99
__version__ = pandas_gbq_version.__version__
1010

1111
__all__ = [

‎pandas_gbq/features.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def bigquery_has_query_and_wait(self):
5454

5555
@property
5656
def pandas_installed_version(self):
57-
import pandas
5857
import packaging.version
58+
import pandas
5959

6060
if self._pandas_installed_version is not None:
6161
return self._pandas_installed_version

‎pandas_gbq/gbq.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ def __init__(
268268
client_secret=None,
269269
):
270270
global context
271-
from google.api_core.exceptions import GoogleAPIError
272-
from google.api_core.exceptions import ClientError
271+
from google.api_core.exceptions import ClientError, GoogleAPIError
272+
273273
from pandas_gbq import auth
274274

275275
self.http_error = (ClientError, GoogleAPIError)
@@ -493,8 +493,7 @@ def _download_results(
493493
num_gib = num_bytes / pandas_gbq.constants.BYTES_IN_GIB
494494
warnings.warn(
495495
f"Recommendation: Your results are {num_gib:.1f} GiB. "
496-
"Consider using BigQuery DataFrames "
497-
"(https://cloud.google.com/bigquery/docs/bigquery-dataframes-introduction) "
496+
"Consider using BigQuery DataFrames (https://bit.ly/bigframes-intro)"
498497
"to process large results with pandas compatible APIs with transparent SQL "
499498
"pushdown to BigQuery engine. This provides an opportunity to save on costs "
500499
"and improve performance. "
@@ -1245,8 +1244,7 @@ def __init__(
12451244

12461245
def _table_ref(self, table_id):
12471246
"""Return a BigQuery client library table reference"""
1248-
from google.cloud.bigquery import DatasetReference
1249-
from google.cloud.bigquery import TableReference
1247+
from google.cloud.bigquery import DatasetReference, TableReference
12501248

12511249
return TableReference(
12521250
DatasetReference(self.project_id, self.dataset_id), table_id
@@ -1287,9 +1285,7 @@ def create(self, table_id, schema):
12871285
Use the generate_bq_schema to generate your table schema from a
12881286
dataframe.
12891287
"""
1290-
from google.cloud.bigquery import DatasetReference
1291-
from google.cloud.bigquery import Table
1292-
from google.cloud.bigquery import TableReference
1288+
from google.cloud.bigquery import DatasetReference, Table, TableReference
12931289

12941290
if self.exists(table_id):
12951291
raise TableCreationError("Table {0} already exists".format(table_id))

‎pandas_gbq/load.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
from typing import Any, Callable, Dict, List, Optional
1010

1111
import db_dtypes
12+
from google.cloud import bigquery
1213
import pandas
1314
import pyarrow.lib
14-
from google.cloud import bigquery
1515

1616
from pandas_gbq import exceptions
1717
import pandas_gbq.schema

‎pandas_gbq/query.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import pandas_gbq.exceptions
1616

17-
1817
logger = logging.getLogger(__name__)
1918

2019

‎pandas_gbq/schema.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import copy
88

9-
109
# API may return data types as legacy SQL, so maintain a mapping of aliases
1110
# from standard SQL to legacy data types.
1211
_TYPE_ALIASES = {

‎samples/snippets/conftest.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import pytest
77
import test_utils.prefixer
88

9-
109
prefixer = test_utils.prefixer.Prefixer("python-bigquery-pandas", "samples/snippets")
1110

1211

‎samples/snippets/noxfile.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import nox
2424

25-
2625
# WARNING - WARNING - WARNING - WARNING - WARNING
2726
# WARNING - WARNING - WARNING - WARNING - WARNING
2827
# DO NOT EDIT THIS FILE EVER!

‎samples/snippets/read_gbq_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
"""System tests for read_gbq code samples."""
66

7-
from . import read_gbq_legacy
8-
from . import read_gbq_simple
7+
from . import read_gbq_legacy, read_gbq_simple
98

109

1110
def test_read_gbq_legacy(project_id):

‎samples/snippets/to_gbq_simple.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def main(project_id, table_id):
1414

1515
# TODO: Set project_id to your Google Cloud Platform project ID.
1616
# project_id = "my-project"
17-
1817
# TODO: Set table_id to the full destination table ID (including the
1918
# dataset ID).
2019
# table_id = 'my_dataset.my_table'

‎setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import setuptools
1212

13-
1413
# Package metadata.
1514

1615
name = "pandas-gbq"

‎tests/system/conftest.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
# Use of this source code is governed by a BSD-style
33
# license that can be found in the LICENSE file.
44

5-
import os
65
import functools
6+
import os
77
import pathlib
88

99
from google.cloud import bigquery
1010
import pytest
1111
import test_utils.prefixer
1212

13-
1413
prefixer = test_utils.prefixer.Prefixer("python-bigquery-pandas", "tests/system")
1514

1615
REPO_DIR = pathlib.Path(__file__).parent.parent.parent

‎tests/system/test_auth.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
from pandas_gbq import auth
1313

14-
1514
IS_RUNNING_ON_CI = "KOKORO_BUILD_ID" in os.environ
1615

1716

‎tests/system/test_gbq.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,20 @@
55
# -*- coding: utf-8 -*-
66

77
import datetime
8-
import packaging.version
98
import sys
109

1110
import numpy as np
11+
import packaging.version
1212
import pandas
13+
from pandas import DataFrame
1314
import pandas.api.types
1415
import pandas.testing as tm
15-
from pandas import DataFrame
16-
17-
import pytz
1816
import pytest
17+
import pytz
1918

2019
from pandas_gbq import gbq
2120
import pandas_gbq.schema
2221

23-
2422
TABLE_ID = "new_test"
2523
PANDAS_VERSION = packaging.version.parse(pandas.__version__)
2624

‎tests/system/test_read_gbq.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55
import collections
66
import datetime
77
import decimal
8-
import packaging.version
98
import random
109

1110
import db_dtypes
1211
from google.cloud import bigquery
12+
import packaging.version
1313
import pandas
1414
import pandas.testing
1515
import pytest
1616

1717
from pandas_gbq.features import FEATURES
1818

19-
2019
QueryTestCase = collections.namedtuple(
2120
"QueryTestCase",
2221
["query", "expected", "use_bqstorage_apis"],

‎tests/system/test_read_gbq_with_bqstorage.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import pytest
1111

12-
1312
pytest.importorskip("google.cloud.bigquery", minversion="1.24.0")
1413

1514

‎tests/system/test_to_gbq.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
# Use of this source code is governed by a BSD-style
33
# license that can be found in the LICENSE file.
44

5+
import collections
56
import datetime
67
import decimal
7-
import collections
88
import random
99

1010
import db_dtypes
1111
import pandas
1212
import pandas.testing
1313
import pytest
1414

15-
1615
pytest.importorskip("google.cloud.bigquery", minversion="1.24.0")
1716

1817

‎tests/unit/test_context.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ def default_bigquery_client(mock_bigquery_client):
2828

2929
@pytest.fixture(autouse=True)
3030
def mock_get_credentials(monkeypatch):
31-
from pandas_gbq import auth
3231
import google.auth.credentials
3332

33+
from pandas_gbq import auth
34+
3435
mock_credentials = mock.MagicMock(google.auth.credentials.Credentials)
3536
mock_get_credentials = mock.Mock()
3637
mock_get_credentials.return_value = (mock_credentials, "my-project")

‎tests/unit/test_gbq.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import pandas_gbq.features
2626
from pandas_gbq.features import FEATURES
2727

28-
2928
pytestmark = pytest.mark.filterwarnings("ignore:credentials from Google Cloud SDK")
3029

3130

‎tests/unit/test_load.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
import pandas.testing
1616
import pytest
1717

18-
from pandas_gbq import exceptions
19-
from pandas_gbq import load
18+
from pandas_gbq import exceptions, load
2019

2120

2221
def load_method(bqclient, api_method):

‎tests/unit/test_query.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
from __future__ import annotations
66

7-
import datetime
87
import concurrent.futures
8+
import datetime
99
from unittest import mock
1010

1111
import freezegun

‎tests/unit/test_timestamp.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import pandas
88
import pandas.testing
9-
109
import pytest
1110

1211

‎tests/unit/test_to_gbq.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# Use of this source code is governed by a BSD-style
33
# license that can be found in the LICENSE file.
44

5-
import google.cloud.bigquery
65
import google.api_core.exceptions
6+
import google.cloud.bigquery
77
from pandas import DataFrame
88
import pytest
99

0 commit comments

Comments
 (0)
Please sign in to comment.