-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deps: make pyarrow and BQ Storage optional dependencies #1282
Merged
Merged
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
b7e2cbb
update dependencies
steffnay 951a43e
Merge branch 'main' of github.com:googleapis/python-bigquery into py-…
steffnay e9c57d6
deps: pyarrow extras
steffnay 47a489b
clean up comments
steffnay fd0c40c
add test pyarrow skips
steffnay 85db3e5
Merge branch 'main' into py-extra
parthea 1fac4d2
replace storage checks
steffnay eaada14
Merge branch 'main' of github.com:googleapis/python-bigquery into py-…
steffnay 61c69e9
update tests
steffnay 95da5c7
Merge branch 'py-extra' of github.com:steffnay/python-bigquery into p…
steffnay e31e4ef
update tests
steffnay b4f7160
Update setup.py
steffnay 2bb6461
update system tests
steffnay 2602e4d
Merge branch 'py-extra' of github.com:steffnay/python-bigquery into p…
steffnay 3a87275
update verify_pandas_imports
steffnay e0a9a2a
add pyarrow guards
steffnay f3dbaea
add datetime check
steffnay 91fccef
change pyarrow import
steffnay ac78a33
update
steffnay 0d89234
add pyarrow skips
steffnay b774b4b
merge
steffnay 79dd4cc
fix types
steffnay 37d7a25
lint
steffnay 9dedf78
Update google/cloud/bigquery/client.py
steffnay 933963e
update pyarrow version
steffnay 93d7639
Merge branch 'py-extra' of github.com:steffnay/python-bigquery into p…
steffnay 45eed33
update test
steffnay 6ac7204
Merge branch 'main' into py-extra
steffnay af00605
lint
steffnay 5bd1f30
Merge branch 'py-extra' of github.com:steffnay/python-bigquery into p…
steffnay ef20ab5
update pyarrow req
steffnay 95aceca
update noxfile
steffnay 12591b3
Merge branch 'main' into py-extra
steffnay d0e9045
remove bignum check
steffnay 5045ead
remove comments
steffnay 050af79
Merge branch 'main' into py-extra
steffnay 01dd2b2
Merge branch 'main' of github.com:googleapis/python-bigquery into py-…
steffnay 1eb5fac
add test importorskip
steffnay f23657b
update test
steffnay 7138f1e
update test
steffnay abb9b8c
update dependency
steffnay d69f8ad
change version
steffnay caa21cb
update imports
steffnay 17d922a
Merge branch 'main' into py-extra
steffnay d52b301
Merge branch 'main' into py-extra
steffnay 21ebf7d
adjust test expectations when google-cloud-bigquery-storage is not av…
tswast 39b173a
export pyarrow exception
tswast 88fa115
whitespace in docstrings
tswast 1b926aa
format minimum bqstorage version string
tswast d71141d
restore optional bqstorage_client
tswast 51332d1
restore optional bqstorage_client (in table.py)
tswast 4c296ae
synchronize constraints and setup.py
tswast 6067f90
synchronize signatures
tswast 6c2b8a5
remove unnecessary bignumeric_type extra
tswast 8196a15
more constraints sync
tswast 5bac083
remove unnecessary mock
tswast dafdb64
fix unittest skip
tswast 805f5d3
synchronize constraints
tswast b85dcf3
adjust shapely
tswast bf4f218
simplify with importorskip
tswast 794f70c
blacken
tswast bab28b5
Merge branch 'main' into py-extra
tswast File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
update
- Loading branch information
commit ac78a3380ce0a21044362b0e181500a0ba21bfba
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,13 +47,10 @@ | |
date_dtype_name = time_dtype_name = "" # Use '' rather than None because pytype | ||
|
||
try: | ||
import pyarrow # type: ignore | ||
import pyarrow.parquet # type: ignore | ||
|
||
pyarrow_import_exception = None | ||
except ImportError as exc: # pragma: NO COVER | ||
import pyarrow | ||
import pyarrow.parquet | ||
except ImportError: # pragma: NO COVER | ||
pyarrow = None | ||
pyarrow_import_exception = exc | ||
|
||
try: | ||
# _BaseGeometry is used to detect shapely objevys in `bq_to_arrow_array` | ||
|
@@ -93,6 +90,7 @@ def _to_wkb(v): | |
|
||
from google.cloud.bigquery import schema | ||
|
||
pyarrow = _helpers.PYARROW_VERSIONS.try_import() | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
@@ -104,6 +102,11 @@ def _to_wkb(v): | |
_NO_DB_TYPES_ERROR = "Please install the 'db-dtypes' package to use this function." | ||
_NO_PYARROW_ERROR = "Please install the 'pyarrow' package to use this function." | ||
|
||
_NO_BQSTORAGE_ERROR = ( | ||
"The google-cloud-bigquery-storage library is not installed, " | ||
"please install google-cloud-bigquery-storage to use bqstorage features." | ||
) | ||
|
||
_PANDAS_DTYPE_TO_BQ = { | ||
"bool": "BOOLEAN", | ||
"datetime64[ns, UTC]": "TIMESTAMP", | ||
|
@@ -691,10 +694,9 @@ def dataframe_to_parquet( | |
|
||
This argument is ignored for ``pyarrow`` versions earlier than ``4.0.0``. | ||
""" | ||
global pyarrow | ||
if pyarrow is None: | ||
raise ValueError("pyarrow is required for BigQuery schema conversion.") | ||
import pyarrow.parquet # type: ignore | ||
pyarrow = _helpers.PYARROW_VERSIONS.try_import(raise_if_error=True) | ||
|
||
import pyarrow.parquet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if we do this here, we can remove the try/except above, right? |
||
|
||
kwargs = ( | ||
{"use_compliant_nested_type": parquet_use_compliant_nested_type} | ||
|
@@ -1019,8 +1021,6 @@ def dataframe_to_json_generator(dataframe): | |
|
||
|
||
def verify_pandas_imports(): | ||
if pyarrow is None: | ||
raise ValueError(_NO_PYARROW_ERROR) from pyarrow_import_exception | ||
if pandas is None: | ||
raise ValueError(_NO_PANDAS_ERROR) from pandas_import_exception | ||
if db_dtypes is None: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to move this to
BQStorageVersions
in theverify_version
method. It could first check if the package is not installed at all?Likewise, we could add a
verify_version
method to PyarrowVersions that raises if the package is not installed and not at the right version.