BhuviTheDataGuy opened a new issue #11822:
URL: https://github.com/apache/airflow/issues/11822


   I have a SQL file like below.
   ```sql
   select * from {{params.table_name }} where data > {{ params.maxdt }}
   ```
   And Im calling a function from python operator. So I need to pass maxdt 
value while calling that python operator.
   ```py
   class SQLTemplatedPythonOperator(PythonOperator):
       template_ext = ('.sql',)
   
   table_list = [public.t1]
   
   for table_name in table_list:
       pull = SQLTemplatedPythonOperator(
       task_id='export_{}'.format(table_name),dag=dag,
       templates_dict={'query': 'public.t1.sql'},
       params = {'table_name': table_name, 'maxdt': 
{{ti.xcom_pull(task_ids='push_result_{}')}}.format(table_name)},
       op_kwargs={'tablename':table_name},
       python_callable=pgexport,
       provide_context=True,
       )
   ```
   There was a task called `push_result_{}.format(table_name)` do some process 
and push a data value to **xcom**. Now here I need to get that value and pass 
it inside my pull task. So my SQL templated query will get the value and pass 
it to the pgexport function.
   
   **pgexport** - it will use postgrestogcs operator to push the results of the 
templated SQL query.
   
   Unfortunately, the syntax I used is not working. 
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to