|
65 | 65 | DEFAULT_BQSTORAGE_CLIENT_INFO = None # type: ignore |
66 | 66 |
|
67 | 67 |
|
| 68 | +from google.cloud.bigquery._http import Connection |
68 | 69 | from google.cloud.bigquery import _job_helpers |
69 | | -from google.cloud.bigquery._job_helpers import make_job_id as _make_job_id |
| 70 | +from google.cloud.bigquery import _pandas_helpers |
| 71 | +from google.cloud.bigquery import _versions_helpers |
| 72 | +from google.cloud.bigquery import enums |
| 73 | +from google.cloud.bigquery import exceptions as bq_exceptions |
| 74 | +from google.cloud.bigquery import job |
70 | 75 | from google.cloud.bigquery._helpers import _get_sub_prop |
71 | 76 | from google.cloud.bigquery._helpers import _record_field_to_json |
72 | 77 | from google.cloud.bigquery._helpers import _str_or_none |
73 | 78 | from google.cloud.bigquery._helpers import _verify_job_config_type |
74 | 79 | from google.cloud.bigquery._helpers import _get_bigquery_host |
75 | | -from google.cloud.bigquery._helpers import BQ_STORAGE_VERSIONS |
76 | 80 | from google.cloud.bigquery._helpers import _DEFAULT_HOST |
77 | | -from google.cloud.bigquery._http import Connection |
78 | | -from google.cloud.bigquery import _pandas_helpers |
79 | | -from google.cloud.bigquery import _versions_helpers |
| 81 | +from google.cloud.bigquery._job_helpers import make_job_id as _make_job_id |
80 | 82 | from google.cloud.bigquery.dataset import Dataset |
81 | 83 | from google.cloud.bigquery.dataset import DatasetListItem |
82 | 84 | from google.cloud.bigquery.dataset import DatasetReference |
83 | | -from google.cloud.bigquery import enums |
84 | 85 | from google.cloud.bigquery.enums import AutoRowIDs |
85 | | -from google.cloud.bigquery import exceptions as bq_exceptions |
86 | | -from google.cloud.bigquery.opentelemetry_tracing import create_span |
87 | | -from google.cloud.bigquery import job |
| 86 | +from google.cloud.bigquery.format_options import ParquetOptions |
88 | 87 | from google.cloud.bigquery.job import ( |
89 | 88 | CopyJob, |
90 | 89 | CopyJobConfig, |
|
98 | 97 | from google.cloud.bigquery.model import Model |
99 | 98 | from google.cloud.bigquery.model import ModelReference |
100 | 99 | from google.cloud.bigquery.model import _model_arg_to_model_ref |
| 100 | +from google.cloud.bigquery.opentelemetry_tracing import create_span |
101 | 101 | from google.cloud.bigquery.query import _QueryResults |
102 | 102 | from google.cloud.bigquery.retry import ( |
103 | 103 | DEFAULT_JOB_RETRY, |
|
113 | 113 | from google.cloud.bigquery.table import TableListItem |
114 | 114 | from google.cloud.bigquery.table import TableReference |
115 | 115 | from google.cloud.bigquery.table import RowIterator |
116 | | -from google.cloud.bigquery.format_options import ParquetOptions |
117 | 116 |
|
118 | 117 | pyarrow = _versions_helpers.PYARROW_VERSIONS.try_import() |
119 | 118 |
|
@@ -545,29 +544,32 @@ def _ensure_bqstorage_client( |
545 | 544 | An existing BigQuery Storage client instance. If ``None``, a new |
546 | 545 | instance is created and returned. |
547 | 546 | client_options: |
548 | | - Custom options used with a new BigQuery Storage client instance if one |
549 | | - is created. |
| 547 | + Custom options used with a new BigQuery Storage client instance |
| 548 | + if one is created. |
550 | 549 | client_info: |
551 | | - The client info used with a new BigQuery Storage client instance if one |
552 | | - is created. |
| 550 | + The client info used with a new BigQuery Storage client |
| 551 | + instance if one is created. |
553 | 552 |
|
554 | 553 | Returns: |
555 | 554 | A BigQuery Storage API client. |
556 | 555 | """ |
| 556 | + |
557 | 557 | try: |
558 | | - from google.cloud import bigquery_storage # type: ignore |
559 | | - except ImportError: |
| 558 | + bigquery_storage = _versions_helpers.BQ_STORAGE_VERSIONS.try_import( |
| 559 | + raise_if_error=True |
| 560 | + ) |
| 561 | + except bq_exceptions.BigQueryStorageNotFoundError: |
560 | 562 | warnings.warn( |
561 | 563 | "Cannot create BigQuery Storage client, the dependency " |
562 | 564 | "google-cloud-bigquery-storage is not installed." |
563 | 565 | ) |
564 | 566 | return None |
565 | | - |
566 | | - try: |
567 | | - BQ_STORAGE_VERSIONS.verify_version() |
568 | 567 | except bq_exceptions.LegacyBigQueryStorageError as exc: |
569 | | - warnings.warn(str(exc)) |
| 568 | + warnings.warn( |
| 569 | + "Dependency google-cloud-bigquery-storage is outdated: " + str(exc) |
| 570 | + ) |
570 | 571 | return None |
| 572 | + |
571 | 573 | if bqstorage_client is None: |
572 | 574 | bqstorage_client = bigquery_storage.BigQueryReadClient( |
573 | 575 | credentials=self._credentials, |
|
0 commit comments