Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standardizes template fields for BaseSQLOperator and adds database as a templated field #39826

Merged

Conversation

nyoungstudios
Copy link
Contributor

@nyoungstudios nyoungstudios commented May 25, 2024

This pull request standardizes the template fields for the BaseSQLOperator and the operators that inherit from it. It also makes the database argument as a templated field so that this example DAG can work.

from airflow.models import DAG
from airflow.operators.python import PythonOperator
from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator

with DAG(
    dag_id="sql_query",
    description="Makes an SQL query to a database",
    schedule_interval=None,
    catchup=False,
) as dag:
    get_database = PythonOperator(
        task_id="get_database",
        python_callable=lambda: "postgres",
    )

    make_sql_query = SQLExecuteQueryOperator(
        task_id="make_sql_query",
        conn_id="my_conn_id",
        sql="SELECT datname FROM pg_database;",
        database=get_database.output,
    )

    get_database >> make_sql_query

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

Copy link
Contributor

@dirrao dirrao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can you check failing static checks?

@nyoungstudios nyoungstudios force-pushed the feat/base-sql-operator-template-fields branch from d38ef1e to 23d782d Compare May 30, 2024 00:18
@eladkal eladkal requested a review from potiuk June 3, 2024 06:10
@potiuk potiuk merged commit 651a6d6 into apache:main Jun 3, 2024
48 checks passed
fdemiane pushed a commit to fdemiane/airflow that referenced this pull request Jun 6, 2024
…` as a templated field (apache#39826)

* standardizes template fields for BaseSQLOperator

* adds template_fields sequence string type

* fixes hook params check in init
syedahsn pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Jun 7, 2024
…` as a templated field (apache#39826)

* standardizes template fields for BaseSQLOperator

* adds template_fields sequence string type

* fixes hook params check in init
romsharon98 pushed a commit to romsharon98/airflow that referenced this pull request Jul 26, 2024
…` as a templated field (apache#39826)

* standardizes template fields for BaseSQLOperator

* adds template_fields sequence string type

* fixes hook params check in init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants