diff --git a/bigframes/bigquery/_operations/ai.py b/bigframes/bigquery/_operations/ai.py index 477ca91366..dd9c4e236b 100644 --- a/bigframes/bigquery/_operations/ai.py +++ b/bigframes/bigquery/_operations/ai.py @@ -1018,7 +1018,7 @@ def _convert_series( def _resolve_connection_id(series: series.Series, connection_id: str | None): return clients.get_canonical_bq_connection_id( - connection_id or series._session._bq_connection, + connection_id or series._session.bq_connection, series._session._project, series._session._location, ) diff --git a/bigframes/functions/_function_session.py b/bigframes/functions/_function_session.py index a456f05417..b0fc25219a 100644 --- a/bigframes/functions/_function_session.py +++ b/bigframes/functions/_function_session.py @@ -162,7 +162,7 @@ def _resolve_bigquery_connection_id( ) -> str: """Resolves BigQuery connection id.""" if not bigquery_connection: - bigquery_connection = session._bq_connection # type: ignore + bigquery_connection = session.bq_connection # type: ignore bigquery_connection = clients.get_canonical_bq_connection_id( bigquery_connection, diff --git a/bigframes/operations/blob.py b/bigframes/operations/blob.py index 9210addaa8..fd8509672d 100644 --- a/bigframes/operations/blob.py +++ b/bigframes/operations/blob.py @@ -311,7 +311,7 @@ def _resolve_connection(self, connection: Optional[str] = None) -> str: Raises: ValueError: If the connection cannot be resolved to a valid string. """ - connection = connection or self._data._block.session._bq_connection + connection = connection or self._data._block.session.bq_connection return clients.get_canonical_bq_connection_id( connection, default_project=self._data._block.session._project, diff --git a/bigframes/session/__init__.py b/bigframes/session/__init__.py index 757bb50a94..23f4178f3d 100644 --- a/bigframes/session/__init__.py +++ b/bigframes/session/__init__.py @@ -374,6 +374,16 @@ def _allows_ambiguity(self) -> bool: def _anonymous_dataset(self): return self._anon_dataset_manager.dataset + @property + def bq_connection(self) -> str: + msg = bfe.format_message( + f"""You are using the BigFrames session default connection: {self._bq_connection}, + which can be different from the BigQuery project default connection. + This default connection may change in the future.""" + ) + warnings.warn(msg, category=FutureWarning) + return self._bq_connection + def __hash__(self): # Stable hash needed to use in expression tree return hash(str(self._session_id)) @@ -2253,7 +2263,7 @@ def _create_bq_connection( ) -> str: """Create the connection with the session settings and try to attach iam role to the connection SA. If any of project, location or connection isn't specified, use the session defaults. Returns fully-qualified connection name.""" - connection = self._bq_connection if not connection else connection + connection = self.bq_connection if not connection else connection connection = bigframes.clients.get_canonical_bq_connection_id( connection_id=connection, default_project=self._project,