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

Remove incorrect example #1932

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
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
24 changes: 0 additions & 24 deletions docs/website/docs/general-usage/incremental-loading.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,30 +655,6 @@ def get_events(last_created_at = dlt.sources.incremental("$", last_value_func=by
yield json.load(f)
```

### Using `last_value_func` for lookback
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VioletM are you sure that this is not working? I thought this is the way you can do lookbacks

The example below uses the `last_value_func` to load data from the past month.
```py
def lookback(event):
last_value = None
if len(event) == 1:
item, = event
else:
item, last_value = event

if last_value is None:
last_value = {}
else:
last_value = dict(last_value)

last_value["created_at"] = pendulum.from_timestamp(item["created_at"]).subtract(months=1)
return last_value

@dlt.resource(primary_key="id")
def get_events(last_created_at = dlt.sources.incremental("created_at", last_value_func=lookback)):
with open("tests/normalize/cases/github.events.load_page_1_duck.json", "r", encoding="utf-8") as f:
yield json.load(f)
```

### Using `end_value` for backfill

You can specify both initial and end dates when defining incremental loading. Let's go back to our Github example:
Expand Down
Loading