【发布时间】:2019-12-16 23:23:04
【问题描述】:
我正在尝试将执行日期作为运行时参数传递给 postgres 运算符
class MyPostgresOperator(PostgresOperator):
template_fields = ('sql','parameters')
task = MyPostgresOperator(
task_id='test_date',
postgres_conn_id='redshift',
sql="test_file.sql",
parameters={'crunch_date':'{{ ds }}'},
dag=dag
)
然后我尝试在sql查询中使用这个参数来接受dag传递的值
select
{{ crunch_date }} as test1,
dag 正确发送参数,但是查询只是采用空值而不是传递的执行日期。有没有办法让带有 redshift 的 postgresql 接受这个参数的正确值?
【问题讨论】:
-
它的红移@a_horse_with_no_name
-
去掉
{{ds}}周围的空格 -
@psychoCoder 我试过了,但它不起作用。虽然 dag 正确发送参数,但我只有 sql 文件无法识别参数的问题