Skip to content

BigQuery traceability labels were not available while using TaskGroup #47297

@jacgeo

Description

@jacgeo

Apache Airflow Provider(s)

google

Versions of Apache Airflow Providers

apache-airflow-providers-google==12.0.0

Apache Airflow version

2.9.3

Operating System

Ubuntu

Deployment

Virtualenv installation

Deployment details

No response

What happened

BigQueryInsertJobOperator set traceability job labels(airflow-dag & airflow-task) in BigQuery jobs. But, when using the BigQueryInsertJobOperator with TaskGroup, the traceability labels were not available

3e2bfb8

What you think should happen instead

traceability_labels = {"airflow-dag": dag_label, "airflow-task": task_label}

The traceability labels should be available for BigQueryInsertJobOperator with TaskGroup

How to reproduce

from datetime import datetime, timedelta
from airflow import DAG
from airflow.providers.google.cloud.operators.bigquery import BigQueryInsertJobOperator
from airflow.operators.dummy import DummyOperator
from airflow.utils.task_group import TaskGroup


default_args = {
    "retries": 1,
    "retry_delay": timedelta(minutes=1),
}


with DAG(
    "test_dag",
    default_args=default_args,
    description="BQ test DAG",
    schedule_interval=timedelta(days=1),
    start_date=datetime(2025, 3, 2),
    catchup=False,
) as dag:
    start = DummyOperator(task_id="start")
    with TaskGroup("taskgroup_1", tooltip="task group #1") as section_1:
        t1 = BigQueryInsertJobOperator(
            task_id="insert_job_1",
            configuration={
                "query": {
                    "query": "SELECT * FROM `project.dataset.table_1`;",
                    "useLegacySql": False,
                }            },
            gcp_conn_id="google_cloud_default",
        )
        t2 = BigQueryInsertJobOperator(
            task_id="insert_job_2",
            configuration={
                "query": {
                    "query": "SELECT * FROM `project.dataset.table_1`;",
                    "useLegacySql": False,
                },
            },
            gcp_conn_id="google_cloud_default",
        )

    end = DummyOperator(task_id="end")

    start >> section_1 >> end

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions