DAG在Airflow中完成运行后如何删除XCOM对象

编程入门 行业动态 更新时间:2024-10-19 02:23:58
本文介绍了DAG在Airflow中完成运行后如何删除XCOM对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在XCOM中有一个巨大的json文件,稍后dag执行完成后就不需要了,但是我仍然在UI中看到包含所有数据的Xcom对象,有没有办法以编程方式删除XCOM DAG运行完成。

I have a huge json file in the XCOM which later I do not need once the dag execution is finished, but I still see the Xcom Object in the UI with all the data, Is there any way to delete the XCOM programmatically once the DAG run is finished.

谢谢

推荐答案

您必须添加任务取决于您的元数据数据库(sqllite,PostgreSql,MySql ..)可在DAG运行完成后删除XCOM。

You have to add a task depends on you metadatadb (sqllite, PostgreSql, MySql..) that delete XCOM once the DAG run is finished.

delete_xcom_task = PostgresOperator( task_id='delete-xcom-task', postgres_conn_id='airflow_db', sql="delete from xcom where dag_id=dag.dag_id and task_id='your_task_id' and execution_date={{ ds }}", dag=dag)

您可以验证您的

数据分析->临时查询-> airflow_db->查询->运行!

Data Profiling -> Ad Hoc Query -> airflow_db -> query -> Run!

更多推荐

DAG在Airflow中完成运行后如何删除XCOM对象

本文发布于:2023-07-07 22:13:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1068492.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对象   DAG   Airflow   XCOM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!