Skip to content

Commit 45b672a

Browse files
authored
feat: support regional endpoints for more bigquery locations (#1061)
* feat: Support bigquery regional endpoints for more locations * typo plural * correct the arg documentation
1 parent f86483d commit 45b672a

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

bigframes/_config/bigquery_options.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,29 @@ def skip_bq_connection_check(self, value: bool):
233233
def use_regional_endpoints(self) -> bool:
234234
"""Flag to connect to regional API endpoints.
235235
236-
.. deprecated:: 0.13.0
237-
Use of regional endpoints is a feature in Preview and
238-
available only in selected regions and projects.
236+
.. note::
237+
Use of regional endpoints is a feature in Preview and available only
238+
in regions "europe-west3", "europe-west9", "europe-west8",
239+
"me-central2", "us-east4" and "us-west1".
239240
240-
Requires that ``location`` is set. For example, to connect to
241-
asia-northeast1-bigquery.googleapis.com, specify
242-
``location='asia-northeast1'`` and ``use_regional_endpoints=True``.
241+
.. deprecated:: 0.13.0
242+
Use of locational endpoints is available only in selected projects.
243+
244+
Requires that ``location`` is set. For supported regions, for example
245+
``europe-west3``, you need to specify ``location='europe-west3'`` and
246+
``use_regional_endpoints=True``, and then BigQuery DataFrames would
247+
connect to the BigQuery endpoint ``bigquery.europe-west3.rep.googleapis.com``.
248+
For not supported regions, for example ``asia-northeast1``, when you
249+
specify ``location='asia-northeast1'`` and ``use_regional_endpoints=True``,
250+
a different endpoint (called locational endpoint, now deprecated, used
251+
to provide weaker promise on the request remaining within the location
252+
during transit) ``europe-west3-bigquery.googleapis.com`` would be used.
243253
244254
Returns:
245255
bool:
246-
A boolean value, where True indicates that a location is set;
247-
otherwise False.
256+
A boolean value, where True indicates that regional endpoints
257+
would be used for BigQuery and BigQuery storage APIs; otherwise
258+
global endpoints would be used.
248259
"""
249260
return self._use_regional_endpoints
250261

bigframes/constants.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@
8080
# https://cloud.google.com/storage/docs/regional-endpoints
8181
REP_ENABLED_BIGQUERY_LOCATIONS = frozenset(
8282
{
83-
"me-central2",
84-
"europe-west9",
8583
"europe-west3",
84+
"europe-west9",
85+
"europe-west8",
86+
"me-central2",
8687
"us-east4",
8788
"us-west1",
8889
}

bigframes/session/clients.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,13 @@
3131
import ibis
3232
import pydata_google_auth
3333

34+
import bigframes.constants
3435
import bigframes.version
3536

3637
_ENV_DEFAULT_PROJECT = "GOOGLE_CLOUD_PROJECT"
3738
_APPLICATION_NAME = f"bigframes/{bigframes.version.__version__} ibis/{ibis.__version__}"
3839
_SCOPES = ["https://www.googleapis.com/auth/cloud-platform"]
3940

40-
# Regions for which Regional Endpoints (REPs) are supported
41-
_REP_SUPPORTED_REGIONS = {
42-
"me-central2",
43-
"europe-west9",
44-
"europe-west3",
45-
"us-east4",
46-
"us-west1",
47-
}
48-
4941

5042
# BigQuery is a REST API, which requires the protocol as part of the URL.
5143
_BIGQUERY_LOCATIONAL_ENDPOINT = "https://{location}-bigquery.googleapis.com"
@@ -129,7 +121,8 @@ def _create_bigquery_client(self):
129121
api_endpoint=(
130122
_BIGQUERY_REGIONAL_ENDPOINT
131123
if self._location is not None
132-
and self._location.lower() in _REP_SUPPORTED_REGIONS
124+
and self._location.lower()
125+
in bigframes.constants.REP_ENABLED_BIGQUERY_LOCATIONS
133126
else _BIGQUERY_LOCATIONAL_ENDPOINT
134127
).format(location=self._location),
135128
)
@@ -201,7 +194,8 @@ def bqstoragereadclient(self):
201194
api_endpoint=(
202195
_BIGQUERYSTORAGE_REGIONAL_ENDPOINT
203196
if self._location is not None
204-
and self._location.lower() in _REP_SUPPORTED_REGIONS
197+
and self._location.lower()
198+
in bigframes.constants.REP_ENABLED_BIGQUERY_LOCATIONS
205199
else _BIGQUERYSTORAGE_LOCATIONAL_ENDPOINT
206200
).format(location=self._location),
207201
)

0 commit comments

Comments
 (0)