Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 气流:从PostgresOperator中的模板化SQL访问ti.xcom\u pull()_Python_Airflow - Fatal编程技术网

Python 气流:从PostgresOperator中的模板化SQL访问ti.xcom\u pull()

Python 气流:从PostgresOperator中的模板化SQL访问ti.xcom\u pull(),python,airflow,Python,Airflow,我有一个任务,从PostgresOperator实例化,如下所示: sql = "select * from {{ ti.xcom_pull(key='foo') }};" task = PostgresOperator(sql=sql) dag无法加载“jinja2.exceptions.UndefinedError:'ti'未定义” 当我用task_实例替换“ti”时,我也会遇到同样的错误。如果有任何帮助,我将不胜感激 奇怪的是,如果我将ti.xcom\u pull(…)替换为ti,它毫无

我有一个任务,从PostgresOperator实例化,如下所示:

sql = "select * from {{ ti.xcom_pull(key='foo') }};"
task = PostgresOperator(sql=sql)
dag无法加载“jinja2.exceptions.UndefinedError:'ti'未定义”

当我用task_实例替换“ti”时,我也会遇到同样的错误。如果有任何帮助,我将不胜感激


奇怪的是,如果我将
ti.xcom\u pull(…)
替换为
ti
,它毫无怨言地呈现,返回
我测试了它:
{task\u instance.xcom\u pull(task\id='taskidwherexcomisset',key='foo')。encode('utf-8')}
,但我确信
{ti.xcom\u pull(key='foo')也会工作

尝试:

示例日志行仅用于显示其工作原理:

[2019-04-25 15:39:24,715] {base_task_runner.py:98} INFO - Subtask: [2019-04-25 15:39:24,714] {postgres_operator.py:52} INFO - Executing: select * from 2019/04/24/;
[2019-04-25 15:39:24,715] {base_task_runner.py:98} INFO - Subtask: [2019-04-25 15:39:24,714] {postgres_operator.py:52} INFO - Executing: select * from 2019/04/24/;