Skip to content

Commit

Permalink
Feat: Allow incremental refresh in combination with REPLACE strategy (
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers authored Mar 22, 2024
1 parent c8ceafb commit 8e3441b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
17 changes: 11 additions & 6 deletions airbyte/sources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from airbyte.progress import progress
from airbyte.results import ReadResult
from airbyte.strategies import WriteStrategy
from airbyte.warnings import PyAirbyteDataLossWarning


if TYPE_CHECKING:
Expand Down Expand Up @@ -655,12 +656,16 @@ def read(
must be True when using the "replace" strategy.
"""
if write_strategy == WriteStrategy.REPLACE and not force_full_refresh:
raise exc.AirbyteLibInputError(
message="The replace strategy requires full refresh mode.",
context={
"write_strategy": write_strategy,
"force_full_refresh": force_full_refresh,
},
warnings.warn(
message=(
"Using `REPLACE` strategy without also setting `full_refresh_mode=True` "
"could result in data loss. "
"To silence this warning, use the following: "
'warnings.filterwarnings("ignore", '
'category="airbyte.warnings.PyAirbyteDataLossWarning")`'
),
category=PyAirbyteDataLossWarning,
stacklevel=1,
)
if cache is None:
cache = get_default_cache()
Expand Down
12 changes: 12 additions & 0 deletions airbyte/warnings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
"""Warnings for the PyAirbyte library."""

from __future__ import annotations


class PyAirbyteDataLossWarning(Warning):
"""Warning for potential data loss.
Users can ignore this warning by running:
> warnings.filterwarnings("ignore", category="airbyte.exceptions.PyAirbyteDataLossWarning")
"""

0 comments on commit 8e3441b

Please sign in to comment.