dlt.destinations.impl.duckdb.sql_client
DuckDBDBApiCursorImpl Objects
class DuckDBDBApiCursorImpl(DBApiCursorImpl)
Use native duckdb data frame support if available
native_cursor
type: ignore
vector_size
vector size is 2048
DuckDbSqlClient Objects
class DuckDbSqlClient(SqlClientBase[duckdb.DuckDBPyConnection], DBTransaction)
warn_if_catalog_equals_dataset_name
def warn_if_catalog_equals_dataset_name() -> None
Checks if the DuckDB connection's current catalog equals the dataset name (schema).
list_secrets
@raise_database_error
def list_secrets() -> Sequence[str]
List secrets that belong to this dataset
use_dataset
def use_dataset() -> None
Makes duckdb schema corresponding to dataset_name the default
WithTableScanners Objects
class WithTableScanners(DuckDbSqlClient, WithSchemas)
memory_db
Internally created in-mem database in case external is not provided
__init__
def __init__(remote_client: JobClientBase,
dataset_name: str,
cache_db: DuckDbCredentials = None,
persist_secrets: bool = False) -> None
Allows to maps data in tables accessed via remote_client as VIEWs in duckdb database.
Creates in memory "cache" database by default or allows for external database via "cache_db".
Will attempt to create views lazily by parsing SQL queries, identifying tables and adding views
before execution.
should_replace_view
@abstractmethod
def should_replace_view(view_name: str,
table_schema: PreparedTableSchema) -> bool
Tells if view view_name should be replaced
create_view_select
@abstractmethod
def create_view_select(table_schema: PreparedTableSchema,
schema: Schema = None) -> Optional[Tuple[str, str]]
Build the SELECT SQL for a view backed by destination data.
Returns (data_location, select_sql) or None when the view
cannot be created (e.g. unsupported file format).
can_create_view
@abstractmethod
def can_create_view(table_schema: PreparedTableSchema) -> bool
Tells if a view for a table table_schema can be created
set_schemas
def set_schemas(schemas: Sequence[Schema]) -> None
Register schemas for multi-schema view creation.
create_views_for_tables
@raise_database_error
def create_views_for_tables(tables: Dict[str, str]) -> None
Add the required tables as views to the duckdb in memory instance.
When a table name appears in multiple schemas, views are grouped by
physical data location. Co-located schemas get their columns merged
into a single SELECT; different locations are combined with
UNION ALL BY NAME.