From 586a6f9a96c60b13282bcced4532bdf5463dd331 Mon Sep 17 00:00:00 2001 From: Garrett Wu Date: Fri, 20 Feb 2026 19:48:45 +0000 Subject: [PATCH 1/3] docs: add bigframes default connection warning --- bigframes/core/blocks.py | 4 ++-- bigframes/dataframe.py | 2 +- bigframes/session/__init__.py | 12 ++++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bigframes/core/blocks.py b/bigframes/core/blocks.py index ff7f2b9899..a764b8d030 100644 --- a/bigframes/core/blocks.py +++ b/bigframes/core/blocks.py @@ -442,7 +442,7 @@ def reset_index( level_ids = self.index_columns expr = self._expr - replacement_idx_type = replacement or self.session._default_index_type + replacement_idx_type = replacement or self.session._default_index_type # type: ignore if set(self.index_columns) > set(level_ids): new_index_cols = [col for col in self.index_columns if col not in level_ids] new_index_labels = [self.col_id_to_index_name[id] for id in new_index_cols] @@ -2382,7 +2382,7 @@ def merge( if ( self.index.is_null or other.index.is_null - or self.session._default_index_type == bigframes.enums.DefaultIndexKind.NULL + or self.session._default_index_type == bigframes.enums.DefaultIndexKind.NULL # type: ignore ): return Block(joined_expr, index_columns=[], column_labels=labels) elif index_cols: diff --git a/bigframes/dataframe.py b/bigframes/dataframe.py index 2a22fc4487..2c376ad5e0 100644 --- a/bigframes/dataframe.py +++ b/bigframes/dataframe.py @@ -4233,7 +4233,7 @@ def to_gbq( # The client code owns this table reference now temp_table_ref = ( - self._session._anon_dataset_manager.generate_unique_resource_id() + self._session._anon_dataset_manager.generate_unique_resource_id() # type: ignore ) destination_table = f"{temp_table_ref.project}.{temp_table_ref.dataset_id}.{temp_table_ref.table_id}" diff --git a/bigframes/session/__init__.py b/bigframes/session/__init__.py index 757bb50a94..1d267aba8a 100644 --- a/bigframes/session/__init__.py +++ b/bigframes/session/__init__.py @@ -374,6 +374,18 @@ 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." + ) + warnings.warn(msg, category=FutureWarning) + return self._bq_connection + + @_bq_connection.setter + def _bq_connection(self, value): + self._bq_connection = value + def __hash__(self): # Stable hash needed to use in expression tree return hash(str(self._session_id)) From ee94f71464b83e2ea37f09c65f14729ae1fe3c6b Mon Sep 17 00:00:00 2001 From: Garrett Wu Date: Fri, 20 Feb 2026 19:55:39 +0000 Subject: [PATCH 2/3] wording --- bigframes/session/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bigframes/session/__init__.py b/bigframes/session/__init__.py index 1d267aba8a..6c875f7abc 100644 --- a/bigframes/session/__init__.py +++ b/bigframes/session/__init__.py @@ -377,7 +377,9 @@ def _anonymous_dataset(self): @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." + 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 From ab9d6105849dc96340bc8855418e0e0f77d1c232 Mon Sep 17 00:00:00 2001 From: Garrett Wu Date: Fri, 20 Feb 2026 20:55:56 +0000 Subject: [PATCH 3/3] fix --- bigframes/bigquery/_operations/ai.py | 2 +- bigframes/core/blocks.py | 4 ++-- bigframes/dataframe.py | 2 +- bigframes/functions/_function_session.py | 2 +- bigframes/operations/blob.py | 2 +- bigframes/session/__init__.py | 8 ++------ 6 files changed, 8 insertions(+), 12 deletions(-) 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/core/blocks.py b/bigframes/core/blocks.py index a764b8d030..ff7f2b9899 100644 --- a/bigframes/core/blocks.py +++ b/bigframes/core/blocks.py @@ -442,7 +442,7 @@ def reset_index( level_ids = self.index_columns expr = self._expr - replacement_idx_type = replacement or self.session._default_index_type # type: ignore + replacement_idx_type = replacement or self.session._default_index_type if set(self.index_columns) > set(level_ids): new_index_cols = [col for col in self.index_columns if col not in level_ids] new_index_labels = [self.col_id_to_index_name[id] for id in new_index_cols] @@ -2382,7 +2382,7 @@ def merge( if ( self.index.is_null or other.index.is_null - or self.session._default_index_type == bigframes.enums.DefaultIndexKind.NULL # type: ignore + or self.session._default_index_type == bigframes.enums.DefaultIndexKind.NULL ): return Block(joined_expr, index_columns=[], column_labels=labels) elif index_cols: diff --git a/bigframes/dataframe.py b/bigframes/dataframe.py index 2c376ad5e0..2a22fc4487 100644 --- a/bigframes/dataframe.py +++ b/bigframes/dataframe.py @@ -4233,7 +4233,7 @@ def to_gbq( # The client code owns this table reference now temp_table_ref = ( - self._session._anon_dataset_manager.generate_unique_resource_id() # type: ignore + self._session._anon_dataset_manager.generate_unique_resource_id() ) destination_table = f"{temp_table_ref.project}.{temp_table_ref.dataset_id}.{temp_table_ref.table_id}" 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 6c875f7abc..23f4178f3d 100644 --- a/bigframes/session/__init__.py +++ b/bigframes/session/__init__.py @@ -375,7 +375,7 @@ def _anonymous_dataset(self): return self._anon_dataset_manager.dataset @property - def _bq_connection(self) -> str: + 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. @@ -384,10 +384,6 @@ def _bq_connection(self) -> str: warnings.warn(msg, category=FutureWarning) return self._bq_connection - @_bq_connection.setter - def _bq_connection(self, value): - self._bq_connection = value - def __hash__(self): # Stable hash needed to use in expression tree return hash(str(self._session_id)) @@ -2267,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,