astro.databases.duckdb
Module Contents
Classes
Handle interactions with Duckdb databases. |
Attributes
- astro.databases.duckdb.DEFAULT_CONN_ID
- class astro.databases.duckdb.DuckdbDatabase(conn_id=DEFAULT_CONN_ID, table=None, load_options=None)
Bases:
astro.databases.base.BaseDatabase
Handle interactions with Duckdb databases.
- Parameters:
conn_id (str) –
table (astro.table.BaseTable | None) –
load_options (astro.options.LoadOptions | None) –
- property sql_type: str
- Return type:
str
- property default_metadata: astro.table.Metadata
Since Duckdb does not use Metadata, we return an empty Metadata instances.
- Return type:
- connection()
Return a Sqlalchemy connection object for the given database.
- Return type:
sqlalchemy.engine.base.Connection
- hook()
Retrieve Airflow hook to interface with the DuckDB database.
- Return type:
duckdb_provider.hooks.duckdb_hook.DuckDBHook
- static get_table_qualified_name(table)
Return the table qualified name.
- Parameters:
table (astro.table.BaseTable) – The table we want to retrieve the qualified name for.
- Return type:
str
- populate_table_metadata(table)
Since Duckdb does not have a concept of databases or schemas, we just return the table as is, without any modifications.
- Parameters:
table (astro.table.BaseTable) –
- Return type:
astro.table.BaseTable
- create_schema_if_needed(schema)
Since Duckdb does not have schemas, we do not need to set a schema here.
- Parameters:
schema (str | None) –
- Return type:
None
- static get_merge_initialization_query(parameters)
Handles database-specific logic to handle index for DuckDB.
- Parameters:
parameters (tuple) –
- Return type:
str
- merge_table(source_table, target_table, source_to_target_columns_map, target_conflict_columns, if_conflicts='exception')
Merge the source table rows into a destination table. The argument if_conflicts allows the user to define how to handle conflicts.
- Parameters:
source_table (astro.table.BaseTable) – Contains the rows to be merged to the target_table
target_table (astro.table.BaseTable) – Contains the destination table in which the rows will be merged
source_to_target_columns_map (dict[str, str]) – Dict of target_table columns names to source_table columns names
target_conflict_columns (list[str]) – List of cols where we expect to have a conflict while combining
if_conflicts (astro.constants.MergeConflictStrategy) – The strategy to be applied if there are conflicts.
- Return type:
None
- get_sqla_table(table)
Return SQLAlchemy table instance
- Parameters:
table (astro.table.BaseTable) – Astro Table to be converted to SQLAlchemy table instance
- Return type:
sqlalchemy.sql.schema.Table
- openlineage_dataset_name(table)
Returns the open lineage dataset name as per https://github.com/OpenLineage/OpenLineage/blob/main/spec/Naming.md Example: /tmp/local.duckdb.table_name
- Parameters:
table (astro.table.BaseTable) –
- Return type:
str
- openlineage_dataset_namespace()
Returns the open lineage dataset namespace as per https://github.com/OpenLineage/OpenLineage/blob/main/spec/Naming.md Example: duckdb://127.0.0.1:22
- Return type:
str
- openlineage_dataset_uri(table)
Returns the open lineage dataset uri as per https://github.com/OpenLineage/OpenLineage/blob/main/spec/Naming.md
- Parameters:
table (astro.table.BaseTable) –
- Return type:
str