You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/07/27 10:41:16 UTC

[GitHub] [airflow] mehmax commented on pull request #17252: Enable specifying dictionary paths in `template_fields_renderers`

mehmax commented on pull request #17252:
URL: https://github.com/apache/airflow/pull/17252#issuecomment-887406217


   @nathadfield I like this a lot. Is there a chance to apply the rendering without specifying `template_field_renderers ` in the Operator Class?
   
   Especially when using decorated tasks or python operators, I like to use the unmodified version of the PythonOperator, where `template_field_renderes` are not specified.
   
   E.g. 
   my dag looks like this
   
   ```
   with DAG('infor_staging_material_v2.0', 
   	default_args=default_args,
   	schedule_interval='25 6 * * *',
       catchup=False,
       template_searchpath='/airflow/home/airflow/sql'
       ) as dag:
   
       @task(default_args=default_args, templates_exts=['.sql'])
       def extract(src_odbc_conn_id : str, dest_odbc_conn_id : str, dest_table : str, sql : str, **kwargs):
            src_odbc_hook = OdbcHook(src_odbc_conn_id)
            dest_odbc_hook = OdbcHook(dest_odbc_conn_id)
   
            df = src_odbc_hook.get_pandas_df(sql)
            df.to_sql(dest_table, con=dest_odbc_hook.get_sqlalchemy_engine())
   
       t1extract = extract(
           src_odbc_conn_id='SOURCE', 
           dest_odbc_conn_id='DESTINATION', 
           sql='SQLSCRIPT.sql',
           dest_table='material'
           )
   
   ```
   
   all of the parameters are collected into op_kwargs, and I would like to prevent specifying
   ```
   op_kwargs.sql
   op_kwargs.dest_table
   ```
   
   as `template_field_renderes` in the _PythonDecoratedOperator class
   
   
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

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