-
Notifications
You must be signed in to change notification settings - Fork 185
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
Docs: Document incremental definition via config.toml #1118
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
85c4428
Documentation update for reading incremental parameters from configur…
dat-a-man 5835801
Updated
dat-a-man 4c224e1
Updated
dat-a-man ef8d718
Merge remote-tracking branch 'origin/devel' into docs/incremental_loa…
dat-a-man 9216610
Update
dat-a-man 761f0b5
Improved wordings and added a bit of explanation.
dat-a-man 965d234
small edits
AstrakhantsevaAA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -614,6 +614,35 @@ Before `dlt` starts executing incremental resources, it looks for `data_interval | |
You can run DAGs manually but you must remember to specify the Airflow logical date of the run in the past (use Run with config option). For such run `dlt` will load all data from that past date until now. | ||
If you do not specify the past date, a run with a range (now, now) will happen yielding no data. | ||
|
||
### Reading incremental loading parameters from configuration | ||
|
||
Let's take the following example to read incremental loading parameters from the configuration file: | ||
|
||
1. In "config.toml", define the parameter `id_after` as follows: | ||
```toml | ||
# Configuration snippet for an incremental resource | ||
[incs.sources.pipeline.inc_res.id_after] | ||
cursor_path = "idAfter" | ||
initial_value = 10 | ||
``` | ||
The `id_after` parameter is defined with a `cursor_path` and an `initial_value`.The `cursor_path` is essential for the resource's progress tracking. | ||
|
||
1. The `id_after` parameter is defined as an incremental source, and its value is retrieved from the configuration using `dlt.config.value`. | ||
```py | ||
@dlt.resource(table_name="incremental_records") | ||
def inc_res(id_after: dlt.sources.incremental = dlt.config.value): | ||
for i in range(100): | ||
yield {"id": i, "idAfter": i, "name": "name-" + str(i)} | ||
|
||
|
||
pipeline = dlt.pipeline( | ||
pipeline_name="pipeline_with_incremental", | ||
destination="duckdb", | ||
) | ||
|
||
pipeline.run(inc_res) | ||
``` | ||
The `inc_res` function generates a range of data, each item being a dictionary with keys `id`, `idAfter`, and `name`. The `idAfter` key is used by the incremental resource to track progress. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And in the text as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay |
||
|
||
## Doing a full refresh | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here we maybe need to change the
table_name
parameter and then name of the function to something meaningful.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also function name please :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done