I am facing a strange error in airflow. I try to remove the Xcom
variables for a task within a certain execution-date; to create and use another instance of the Xcom
variable for the same task.
Why do I want to do this? Because the value of this Xcom
variable changes during the day, and sometimes I notice a conflict, the first value is used, which messes up my workflows. I'd be happy to explain with examples if needed.
When I execute this query :
SELECT * FROM xcom WHERE dag_id='datamart_integration.tracking_marketing' AND TASK_ID='find_file' AND execution_date LIKE '%2020-12-14%'
I get 2 rows of data.
id key value timestamp execution_date task_id dag_id
4969 return_value b'["DTM_DATALAKE_TRACKING_MARKETING_20201214_20201214060143.zip"]' 2020-12-14 10:22:50.085745 2020-12-14 05:40:38 find_file datamart_integration.tracking_marketing
5139 return_value b'["DTM_DATALAKE_TRACKING_MARKETING_20201214_20201214060143.zip", "DTM_DATALAKE_TRACKING_MARKETING_20201214_20201214130326.zip"]' 2020-12-14 16:50:55.596651 2020-12-14 13:35:44 find_file datamart_integration.tracking_marketing
But when I execute this query :
DELETE FROM xcom WHERE dag_id='datamart_integration.tracking_marketing' AND TASK_ID='find_file' AND execution_date LIKE '%2020-12-14%'
I get
Execution failed on sql 'DELETE FROM xcom WHERE dag_id='datamart_integration.tracking_marketing' AND TASK_ID='find_file' AND execution_date LIKE '%2020-12-14%'': (1292, "Incorrect datetime value: '%2020-12-14%' for column 'execution_date' at row 1")
But I think the real problem occurs when I try these queries :
DELETE FROM xcom WHERE dag_id='datamart_integration.tracking_marketing' AND TASK_ID='find_file' AND execution_date BETWEEN '2020-12-14 00:00:00' AND '2020-12-14 23:59:59'
DELETE FROM xcom WHERE dag_id='datamart_integration.tracking_marketing' AND TASK_ID='find_file' AND execution_date LIKE '2020-12-14%'
I get
'NoneType' object is not iterable
No data
I'm thinking perhaps the airflow database is protected from deletion/insertion unless specified somewhere, and somehow? But then these errors would be confusing.
The airflow_db is initiated with MySQL
, and I'm working on composer.