GitHub user raphaelauv closed a discussion: Templating of params dict values
not working
Templating of values of the dict `params` are not templated before usage for
`template_ext`
I have a file myquery.sql :
```sql
CREATE OR REPLACE EXTERNAL TABLE
{{params.project_id}}.{{params.dataset}}.{{params.tmp_table}}
```
```python
path_to_sql = "myquery.sql"
dag = DAG(dag_name,
schedule_interval="@daily",
template_searchpath=TEMPLATE_SEARCHPATH,
default_args=default_args)
class MyBigQueryExecuteQueryOperator(BigQueryExecuteQueryOperator):
template_fields = ("params",) + BigQueryExecuteQueryOperator.template_fields
MyBigQueryExecuteQueryOperator(
dag=dag,
task_id="something",
gcp_conn_id="a_conn",
sql=path_to_sql,
params={
"project_id": "{{ var.value.get('a_variable') }}",
"dataset": "toto",
"tmp_table": "aaaa_{date}".format(date="{{ ds_nodash }}"),
},
use_legacy_sql=False
```
print
```sql
CREATE OR REPLACE EXTERNAL TABLE {{ var.value.get('a_variable') }}.toto.aaaa_{{
ds_nodash }}
```
and not
```sql
CREATE OR REPLACE EXTERNAL TABLE the_value_of_variable.toto.aaaa_2021.....
```
Thank you very much
GitHub link: https://github.com/apache/airflow/discussions/18812
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]