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 2022/06/11 02:43:52 UTC

[GitHub] [airflow] josh-fell commented on issue #24014: Task mapping against 'params'

josh-fell commented on issue #24014:
URL: https://github.com/apache/airflow/issues/24014#issuecomment-1152839870

   @hammerhead See the "Anything else" section of #24388, but you should be able to still map via `parameters` for the `DELETE` DML in a Jinja-templated SQL using `{{ task.mapped_kwargs.parameters[ti.map_index].<attribute>}}` as a workaround.
   
   Assuming the desired SQL `DELETE FROM {table_fqn} WHERE {column} = {value};`, you could try:
   
   ```python
   sql = """
   DELETE FROM {{ task.mapped_kwargs.parameters[ti.map_index].table_fqn }}
   WHERE {{ task.mapped_kwargs.parameters[ti.map_index].column }} = {{ task.mapped_kwargs.parameters[ti.map_index].value }};"""
   
   PostgresOperator.partial(
       task_id="delete_partitions",
       postgres_conn_id="createdb_connection",
       sql=sql,
   ).expand(parameters=[
       {"table_fqn": "tbl1", "column": "col1", "value": "val1"},
       {"table_fqn": "tbl2", "column": "col2", "value": "val3"},
   )
   ```
   Does this help?


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