Skip to content
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

feat: add an option to turn off time travel #999

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions bigframes/_config/bigquery_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def __init__(
skip_bq_connection_check: bool = False,
*,
ordering_mode: Literal["strict", "partial"] = "strict",
enable_time_travel: bool = True,
):
self._credentials = credentials
self._project = project
Expand All @@ -93,6 +94,7 @@ def __init__(
self._session_started = False
# Determines the ordering strictness for the session.
self._ordering_mode = _validate_ordering_mode(ordering_mode)
self._enable_time_travel = True

@property
def application_name(self) -> Optional[str]:
Expand Down Expand Up @@ -253,3 +255,23 @@ def ordering_mode(self) -> Literal["strict", "partial"]:
@ordering_mode.setter
def ordering_mode(self, ordering_mode: Literal["strict", "partial"]) -> None:
self._ordering_mode = _validate_ordering_mode(ordering_mode)

@property
def enable_time_travel(self) -> bool:
"""An option to enable or disable time travel data retention window

Args:
value (bool):
A boolean value, where a value is True if the time travel is
enabled, otherwise False.

Returns:
bool:
A boolean value, where a value is True if the time travel is
enabled, otherwise False.
"""
return self.enable_time_travel

@enable_time_travel.setter
def enable_time_travel(self, value: bool = True) -> None:
self._enable_time_travel = value
2 changes: 1 addition & 1 deletion bigframes/session/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def read_gbq_table_streaming(
df = self._loader.read_gbq_table(
table,
api_name="read_gbq_table_steaming",
enable_snapshot=False,
enable_time_travel=False,
index_col=bigframes.enums.DefaultIndexKind.NULL,
)

Expand Down
6 changes: 3 additions & 3 deletions bigframes/session/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def read_gbq_table(
api_name: str,
use_cache: bool = True,
filters: third_party_pandas_gbq.FiltersType = (),
enable_snapshot: bool = True,
enable_time_travel=bigframes.options.bigquery.enable_time_travel,
) -> dataframe.DataFrame:
import bigframes.dataframe as dataframe

Expand Down Expand Up @@ -338,7 +338,7 @@ def read_gbq_table(
else (*columns, *[col for col in index_cols if col not in columns])
)

enable_snapshot = enable_snapshot and bf_read_gbq_table.validate_table(
enable_time_travel = enable_time_travel and bf_read_gbq_table.validate_table(
self._bqclient, table_ref, all_columns, time_travel_timestamp, filter_str
)

Expand Down Expand Up @@ -366,7 +366,7 @@ def read_gbq_table(
table,
schema=schema,
predicate=filter_str,
at_time=time_travel_timestamp if enable_snapshot else None,
at_time=time_travel_timestamp if enable_time_travel else None,
primary_key=index_cols if is_index_unique else (),
session=self._session,
)
Expand Down
Loading