extract.hints
make_hints
def make_hints(
table_name: TTableHintTemplate[str] = None,
parent_table_name: TTableHintTemplate[str] = None,
write_disposition: TTableHintTemplate[TWriteDisposition] = None,
columns: TTableHintTemplate[TAnySchemaColumns] = None,
primary_key: TTableHintTemplate[TColumnNames] = None,
merge_key: TTableHintTemplate[TColumnNames] = None,
schema_contract: TTableHintTemplate[TSchemaContract] = None,
table_format: TTableHintTemplate[TTableFormat] = None
) -> TResourceHints
A convenience function to create resource hints. Accepts both static and dynamic hints based on data.
This method accepts the same table hints arguments as dlt.resource
decorator.
DltResourceHints Objects
class DltResourceHints()
table_name
@property
def table_name() -> TTableHintTemplate[str]
Get table name to which resource loads data. May return a callable.
columns
@property
def columns() -> TTableHintTemplate[TTableSchemaColumns]
Gets columns' schema that can be modified in place
compute_table_schema
def compute_table_schema(item: TDataItem = None) -> TTableSchema
Computes the table schema based on hints and column definitions passed during resource creation. item
parameter is used to resolve table hints based on data.
apply_hints
def apply_hints(
table_name: TTableHintTemplate[str] = None,
parent_table_name: TTableHintTemplate[str] = None,
write_disposition: TTableHintTemplate[TWriteDisposition] = None,
columns: TTableHintTemplate[TAnySchemaColumns] = None,
primary_key: TTableHintTemplate[TColumnNames] = None,
merge_key: TTableHintTemplate[TColumnNames] = None,
incremental: Incremental[Any] = None,
schema_contract: TTableHintTemplate[TSchemaContract] = None,
additional_table_hints: Optional[Dict[str,
TTableHintTemplate[Any]]] = None,
table_format: TTableHintTemplate[TTableFormat] = None) -> None
Creates or modifies existing table schema by setting provided hints. Accepts both static and dynamic hints based on data.
This method accepts the same table hints arguments as dlt.resource
decorator with the following additions.
Skip the argument or pass None to leave the existing hint.
Pass empty value (for a particular type i.e. "" for a string) to remove a hint.
parent_table_name (str, optional): A name of parent table if foreign relation is defined. Please note that if you use merge, you must define root_key
columns explicitly
incremental (Incremental, optional): Enables the incremental loading for a resource.
Please note that for efficient incremental loading, the resource must be aware of the Incremental by accepting it as one if its arguments and then using are to skip already loaded data.
In non-aware resources, dlt
will filter out the loaded values, however, the resource will yield all the values again.