任务实例未定义

问题描述

我有一个要传递给xcom的对象,希望从操作员那里读取。

这是我的接线员:

load_csv = GCSToBigQueryOperator(
    task_id='gcs_to_bigquery',bucket='test',source_objects=['{{ execution_date.strftime("%Y-%m") }}'],providers=True,destination_project_dataset_table=f'{stg_dataset_name}' + '.' + '{{ execution_date.strftime("%Y_%m") }}',schema_fields={{ti.xcom_pull(task_ids='print_the_context')}},write_disposition='WRITE_TRUNCATE',provide_context=True,dag=dag)

我想将xcom的值传递给schema_fields变量。

我正在尝试使用以下模板{{ti.xcom_pull(task_ids='print_the_context')}}访问对象,但是我有it is not defined ...

这是怎么了?

解决方法

不幸的是,目前无法实现

因此,您无法通过XCOM模板为schema_fields提供价值


也就是说,尽管我不知道GCSToBigQueryOperator的内部结构,但我可以看到2种可能的解决方案

  • (直接)改为使用schema_object field

    :param schema_object: If set,a GCS object path pointing to a .json file that
         contains the schema for the table. (templated)
         Parameter must be defined if 'schema_fields' is null and autodetect is False.
     :type schema_object: str
    
  • 您可以尝试对其进行子类化,并将schema_fields包含在template_fields


有趣的读物

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...