airflow.providers.common.sql.hooks.lineage¶
Attributes¶
Classes¶
Keys for the SQL job hook-level lineage extra entry. |
Functions¶
|
Report a single SQL execution to the hook lineage collector. |
Module Contents¶
- class airflow.providers.common.sql.hooks.lineage.SqlJobHookLineageExtra[source]¶
-
Keys for the SQL job hook-level lineage extra entry.
Reported via
get_hook_lineage_collector().add_extra().KEYis the extra entry key;VALUE__*are the keys inside the value dict (one entry per SQL statement so job_id, SQL text, row count, default_db, etc. stay stitched).
- airflow.providers.common.sql.hooks.lineage.send_sql_hook_lineage(*, context, sql, sql_parameters=None, cur=None, job_id=None, row_count=None, default_db=None, default_schema=None, extra=None)[source]¶
Report a single SQL execution to the hook lineage collector.
Call this after running a SQL statement so that hook lineage collectors can associate the execution with the task. Each call produces one extra entry in the collector; when executing multiple statements in one hook run, one should call this function separately for each sql job, so that job_id, SQL text, row count, and other fields stay tied together per statement.
Usable from any hook: pass the hook instance as
context. Not limited toDbApiHooksubclasses.- Parameters:
context (airflow.providers.common.compat.lineage.hook.LineageContext) – Lineage context, typically the hook instance. Must be valid for
get_hook_lineage_collector().add_extra(context=..., ...).sql (str | list[str]) – The SQL statement that was executed (or a representative string).
sql_parameters (Any) – Optional parameters bound to the statement.
cur (Any) – Optional DB-API cursor after execution. If given, job_id is taken from
query_idorsfqidwhen not provided explicitly, and row_count fromcur.rowcountwhen applicable (PEP 249).job_id (str | None) – Explicit job ID; used instead of cursor-derived value when set.
row_count (int | None) – Explicit row count; used instead of cursor-derived value when set.
default_db (str | None) – Default database/catalog name for this execution context.
default_schema (str | None) – Default schema name for this execution context.
extra (dict[str, Any] | None) – Optional additional key-value data to attach to this lineage entry.