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

Document incremental definition via config.toml #1077

Closed
sultaniman opened this issue Mar 11, 2024 · 4 comments
Closed

Document incremental definition via config.toml #1077

sultaniman opened this issue Mar 11, 2024 · 4 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@sultaniman
Copy link
Contributor

Documentation description

Dlt user from community asked a question on initializing incremental from configuration

Is it a limitation of dlt that it cannot read configs when they are put inside the dlt.sources.incremental(...) block?

# resource for pipeline `talon_one_referrals_pipeline`
@dlt.resource(write_disposition="merge", table_name="referrals", primary_key="id")
def referrals_resource(
    api_secret_key=dlt.secrets.value,
    createdAfter=dlt.sources.incremental(
        "created",
        # BUG: cannot read this initial_value from config file
        initial_value=dlt.config.value,
        last_value_func=last_value_func,
    ),
    campaign_ids=dlt.config.value,
    schema_contract=SCHEMA_CONTRACT
):


[talon_one_referrals_pipeline]
campaign_ids = ["17", "14"]
initial_value = "2020-01-01T00:00:00.000000Z"

In fact we support loading incremental parameters from configuration below is the working example

[incs.sources.pipeline.inc_res.id_after]
cursor_path="idAfter"
initial_value=10
@dlt.resource(table_name="incs")
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="incs",
    destination="duckdb",
)

pipeline.run(inc_res)

Are you a dlt user?

Yes, I'm already a dlt user.

@sultaniman
Copy link
Contributor Author

@dat-a-man do you need some kind of detailed explanation to document this?

@dat-a-man
Copy link
Collaborator

Thank you, @sultaniman , It looks good and I will manage. Will add it to incremental loading docs

@sultaniman sultaniman added the documentation Improvements or additions to documentation label Mar 13, 2024
@sultaniman
Copy link
Contributor Author

Awesome @dat-a-man, thank you as well!

@sultaniman sultaniman removed their assignment Mar 13, 2024
@rudolfix rudolfix moved this from Todo to In Progress in dlt core library Mar 18, 2024
@dat-a-man
Copy link
Collaborator

Created PR: 1118

@rudolfix rudolfix closed this as completed Apr 9, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in dlt core library Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: Done
Development

No branches or pull requests

3 participants