python-3.x - 示例 dag 尝试将 execution_date 参数保存为 null
问题描述
从气流 2.0.1 升级到 2.1.0 后我有一个问题。当我运行示例 dag 并且失败时,我无法在task_fail
表中保存一行。
ERROR: null value in column "execution_date" violates not-null constraint
from datetime import datetime, timedelta
from airflow import DAG
from airflow.operators.python import PythonOperator
from test_methods import test_python_method, test_python_log
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'retries': 1,
'retry_delay': timedelta(minutes=5)
}
with DAG(
'Sample-Dag',
default_args=default_args,
start_date= datetime(2021, 1, 1),
schedule_interval=timedelta(minutes=10),
catchup=False,
) as dag:
task_1 = PythonOperator(
task_id='Task-1',
python_callable=test_python_method,
)
task_2 = PythonOperator(
task_id='Task-2',
python_callable=test_python_log,
)
task_1 >> task_2
如果有帮助,我可以添加配置,但这可能是因为 Dag 结构。
解决方案
我想你可能没有这样做airflow db upgrade
。
在迁移到较新的 Airflow 版本后,您始终必须运行它。
推荐阅读
- android - 在Android上从相机意图获取图像
- reactjs - React Native 中的 i18next:import {t} 不起作用(在 React Web 中有效)
- debugging - 使用 elm reactor 时是否可以显示 Elm 的调试器?
- java - 如何在 Java 中使用 Rest-assured 来使用多部分文件附件?
- facebook - Graph API:是否可以在我也是成员的 Facebook 群组中获取 Facebook 成员的姓名和位置?
- java - 如何从 javafx 中的切换按钮获取文本
- html - 将 SVG 元素放在另一个元素上
- javascript - 在 JavaScript 中将时间“1hr 30m 4s”解析为提前时间
- android - React Native:来自多个域的 Axios 网络错误
- javascript - 如何使用 redux 从数据库中删除数据?