-
Notifications
You must be signed in to change notification settings - Fork 13.7k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Params Fail to Evaluate In Dag Body #39651
Comments
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval. |
This rendered because you have |
Thanks for your response @Taragolis! For my use-case, I'd like to determine the SQL file with a param provided in the UI |
You can use Jinja's For example, using this SQL file; # dags/sql/default.sql
SELECT 'from a templated file'; and this task definition: from airflow.models.dag import DAG
from airflow.models.param import Param
from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
with DAG(
"generate_password_dag",
params={"test": Param("default", type="string")},
):
sql_operator = SQLExecuteQueryOperator(
task_id="sql_operator",
sql="{% include 'sql/' ~ params.test ~ '.sql' %}",
conn_id="postgres",
) In the above task definition, @oliver-helix Can you try that approach and see if it works please? |
Thank you @josh-fell! This indeed works. Curious why |
It doesn't work by design, see: #39651 (comment)
It is just a Jinja statement which rendered |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Apache Airflow version
Other Airflow 2 version (please specify below)
If "Other Airflow 2 version" selected, which one?
2.7.2
What happened?
When providing airflow params, the parameter is not available in the body of the airflow dag.
What you think should happen instead?
The value should be available in the airflow dag
How to reproduce
Operating System
NA
Versions of Apache Airflow Providers
NA
Deployment
Official Apache Airflow Helm Chart
Deployment details
NA
Anything else?
NA
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: