dlt.common.destination.client
StorageSchemaInfo Objects
class StorageSchemaInfo(NamedTuple)
from_normalized_mapping
@classmethod
def from_normalized_mapping(
cls, normalized_doc: Dict[str, Any],
naming_convention: NamingConvention) -> "StorageSchemaInfo"
Instantiate this class from mapping where keys are normalized according to given naming convention
Arguments:
normalized_doc- Mapping with normalized keys (e.g. {Version: ..., SchemaName: ...})naming_convention- Naming convention that was used to normalize keys
Returns:
StorageSchemaInfo- Instance of this class
to_normalized_mapping
def to_normalized_mapping(
naming_convention: NamingConvention) -> Dict[str, Any]
Convert this instance to mapping where keys are normalized according to given naming convention
Arguments:
naming_convention- Naming convention that should be used to normalize keys
Returns:
Dict[str, Any]: Mapping with normalized keys (e.g. {Version: ..., SchemaName: ...})
StateInfo Objects
@dataclasses.dataclass
class StateInfo()
from_normalized_mapping
@classmethod
def from_normalized_mapping(
cls, normalized_doc: Dict[str, Any],
naming_convention: NamingConvention) -> "StateInfo"
Instantiate this class from mapping where keys are normalized according to given naming convention
Arguments:
normalized_doc- Mapping with normalized keys (e.g. {Version: ..., PipelineName: ...})naming_convention- Naming convention that was used to normalize keys
Returns:
StateInfo- Instance of this class
DestinationClientConfiguration Objects
@configspec
class DestinationClientConfiguration(BaseConfiguration)
destination_type
which destination to load data to
destination_name
name of the destination
data_location
def data_location() -> Optional[str]
Returns the data location that the query engine of this destination can access with the supplied credentials.
The location is limited to data that the engine accesses without an additional attach to another location and without federation.
Returns:
Optional[str]-Nonewhen the destination has no data location, for example a reverse ETL sink. Such a destination has no query engine, so it accesses no data.
Raises:
ConfigurationValueError- When the location cannot be computed from this configuration.
fingerprint
def fingerprint() -> str
Returns a destination fingerprint derived from selected configuration fields.
is_same_location
def is_same_location(other: "DestinationClientConfiguration") -> bool
Checks if self and other have the same destination type. Also checks if they
store data in the same location.
Raises:
ConfigurationValueError- When either location cannot be computed.
can_read_from
def can_read_from(other: "DestinationClientConfiguration") -> bool
Returns True if self can read data from other.
In case of SQL engines it is an ability to SELECT / JOIN
This check must be as wide as possible. On many destinations it describes all data that the query engine joins together. A destination that federates or attaches data locations also includes that data, when it implements the attach interface. Only duckdb implements the interface now.
can_write_from
def can_write_from(other: "DestinationClientConfiguration") -> bool
Returns true if self can write data from other
In case of SQL engines it is an ability to INSERT FROM
__str__
def __str__() -> str
Return displayable destination location
credentials_type
@classmethod
def credentials_type(
cls,
config: "DestinationClientConfiguration" = None
) -> Type[CredentialsConfiguration]
Figure out credentials type, using hint resolvers for dynamic types
For correct type resolution of filesystem, config should have bucket_url populated
WithAttachableEngine Objects
class WithAttachableEngine()
Marks a destination with a query engine that attaches foreign datasets. A foreign engine can attach the datasets of this destination in turn.
This class must come first in the list of mixins, so that can_read_from here overrides
the base class.
attach_type
def attach_type() -> Optional["TAttachType"]
Returns the engine type that can run the attach statements of this destination.
can_attach
def can_attach(attach_type: "TAttachType") -> bool
Checks if the engine of this destination can run attach_type statements.
needs_attach
def needs_attach(other: DestinationClientConfiguration) -> bool
Checks if this query engine must attach other, or if it already accesses the data
of other.
can_read_from
def can_read_from(other: DestinationClientConfiguration) -> bool
Returns True when this query engine already accesses other, or can attach it.
DestinationClientDwhConfiguration Objects
@configspec
class DestinationClientDwhConfiguration(DestinationClientConfiguration)
Configuration of a destination that supports datasets/schemas
dataset_name
dataset name in the destination to load data to, for schemas that are not default schema, it is used as dataset prefix
default_schema_name
name of default schema to be used to name effective dataset to load data to
replace_strategy
How to handle replace disposition for this destination, uses first strategy from caps if not declared
staging_dataset_name_layout
Layout for staging dataset, where %s is replaced with dataset name. placeholder is optional
enable_dataset_name_normalization
Whether to normalize the dataset name. Affects staging dataset as well.
info_tables_query_threshold
Threshold for information schema tables query, if exceeded tables will be filtered in code.
normalize_dataset_name
def normalize_dataset_name(schema: Schema) -> str
Builds full db dataset (schema) name out of configured dataset name and schema name: {dataset_name}_{schema.name}. The resulting name is normalized.
If default schema name is None or equals schema.name, the schema suffix is skipped.
normalize_staging_dataset_name
def normalize_staging_dataset_name(schema: Schema) -> str
Builds staging dataset name out of dataset_name and staging_dataset_name_layout.
needs_dataset_name
@classmethod
def needs_dataset_name(cls) -> bool
Checks if configuration requires dataset name to be present. Empty datasets are allowed ie. for schema-less destinations like weaviate or clickhouse
DestinationClientStagingConfiguration Objects
@configspec
class DestinationClientStagingConfiguration(DestinationClientDwhConfiguration)
Configuration of a staging destination, able to store files with desired layout at bucket_url.
Also supports datasets and can act as standalone destination.
warn_unsafe_layout_separators
Warns when a layout separator around {table_name} can also occur inside a table name.
DestinationClientDwhWithStagingConfiguration Objects
@configspec
class DestinationClientDwhWithStagingConfiguration(
DestinationClientDwhConfiguration)
Configuration of a destination that can take data from staging destination
staging_config
configuration of the staging, if present, injected at runtime
truncate_tables_on_staging_destination_before_load
If dlt should truncate the tables on staging destination before loading data.
LoadJob Objects
class LoadJob(ABC)
A stateful load job, represents one job file
job_id
def job_id() -> str
The job id that is derived from the file name and does not changes during job lifecycle
file_name
def file_name() -> str
A name of the job file
state
@abstractmethod
def state() -> TLoadJobState
Returns current state. Should poll external resource if necessary.
failed_message
@abstractmethod
def failed_message() -> str
The error message in failed or retry states
exception
@abstractmethod
def exception() -> BaseException
The exception associated with failed or retry states
set_final_state
@abstractmethod
def set_final_state(state: TLoadJobState,
failed_message: Optional[str] = None) -> None
Forces the job into a terminal state without running it.