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

logs warning if deduplication state is large #1877

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
improves error message, refactors magic number
  • Loading branch information
willi-mueller committed Sep 27, 2024
commit 4e59fb7f5c95c905df94354d1e48bb1cbf4c8bf4
5 changes: 3 additions & 2 deletions dlt/extract/incremental/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,11 @@ def __call__(self, rows: TDataItems, meta: Any = None) -> Optional[TDataItems]:
# add directly computed hashes
unique_hashes.update(transformer.unique_hashes)
self._cached_state["unique_hashes"] = list(unique_hashes)
dedup_count = len(self._cached_state["unique_hashes"])
DEDUP_WARNING_THRESHOLD = 200
if len(self._cached_state["unique_hashes"]) > 200:
if dedup_count > DEDUP_WARNING_THRESHOLD:
logger.warning(
f"There are over {DEDUP_WARNING_THRESHOLD} records to be deduplicated because"
f"There are {dedup_count} records to be deduplicated because"
f" they share the same primary key `{self.primary_key}`."
)
return rows
Expand Down
2 changes: 1 addition & 1 deletion tests/extract/test_incremental.py
Original file line number Diff line number Diff line change
Expand Up @@ -2604,6 +2604,6 @@ def some_data(
p = dlt.pipeline(pipeline_name=uniq_id())
p.extract(some_data(1))
logger_spy.assert_any_call(
"There are over 200 records to be deduplicated because they share the same primary key"
"There are 201 records to be deduplicated because they share the same primary key"
f" `{primary_key}`."
)
Loading