Skip to content

Bug: SQLExecuteQueryOperator does not pass extra_dejson values to hook_params #49273

@kandharvishnu

Description

@kandharvishnu

Apache Airflow Provider(s)

common-sql

Versions of Apache Airflow Providers

The SQLExecuteQueryOperator extends BaseSQLOperator, which supports hook_params. However, the values in the extra_dejson field are not currently passed to hook_params within SQLExecuteQueryOperator.

This creates unnecessary redundancy when the same parameters need to be specified while creating operator. To reduce this duplication and improve consistency, the extra_dejson values should be passed to hook_params by default.

Expected Behavior:
Values in extra_dejson should be automatically added to hook_params unless explicitly overridden.

Apache Airflow version

2.10.5

Operating System

debian

Deployment

Astronomer

Deployment details

Local

What happened

No response

What you think should happen instead

No response

How to reproduce

  1. Create a Google BigQuery connection in Airflow.

  2. In the connection, set:

Image

Backend connection has use_legacy_sql as False

{'/usr/local/airflow/include/service-account-key.json', 'num_retries': 5, 'is_anonymous': False, 'use_legacy_sql': False, 'priority': 'BATCH'}

Image

  1. In your DAG, use the SQLExecuteQueryOperator and reference this connection:

    SQLExecuteQueryOperator(
        task_id="run_query",
        sql="SELECT * FROM `project.dataset.table`",
        conn_id="my_bq_connection",
    )
    
  2. Observe that use_legacy_sql is not picked up from the connection's extra_dejson.

  3. You are forced to manually pass it like this:

    SQLExecuteQueryOperator(
        task_id="run_query",
        sql="SELECT * FROM `project.dataset.table`",
        conn_id="my_bq_connection",
        hook_params={"use_legacy_sql": False}
    )

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions