Overview
The@dlt.source decorator transforms a function returning one or more dlt resources into a dlt source. A source is a logical grouping of resources that are often extracted and loaded together, associated with a schema that describes the structure of the loaded data.
Signature
Parameters
A function that returns a dlt resource or a list of resources, or a list of any data items that can be loaded by dlt.
A name of the source which is also the name of the associated schema. If not present, the function name will be used.
Configuration section that comes right after
sources in default layout. If not present, the current python module name will be used.Default layout is sources.<section>.<name>.<key_name>.A schema hint that sets the maximum depth of nested table above which the remaining nodes are loaded as structs or JSON.
Enables merging on all resources by propagating row key from root to all nested tables. This option is most useful if you plan to change write disposition of a resource to disable/enable merge.
An explicit
Schema instance to be associated with the source. If not present, dlt creates a new Schema object with provided name. If such Schema already exists in the same folder as the module containing the decorated function, such schema will be loaded from file.Schema contract settings that will be applied to this source and all its resources.
A specification of configuration and secret values required by the source.
If
True, resource generators will be extracted in parallel with other resources. Transformers that return items are also parallelized. Non-eligible resources are ignored.Returns
A wrapped source function that when called returns a
DltSource instance which can be loaded using dlt.pipeline().run().Configuration Injection
The decorator automatically binds the source function arguments to secret and config values:usernameis a required, explicit python argumentchess_urlis required and will be taken fromconfig.tomlif not explicitly passedapi_secretis required and will be taken fromsecrets.tomlif not explicitly passedtitlehas a default value of “GM”