Python 气流宏未转换为日期

Python 气流宏未转换为日期,python,jinja2,airflow,Python,Jinja2,Airflow,我有下面的配置单元操作符,我必须根据日期添加分区 HiveOperator(task_id='add_partition_{}'.format(state), hql='alter table my_db.state_wise_records add partition (event_date="{{ ds }}", state="{state}") location "/user/cloudera/state_wise

我有下面的配置单元操作符,我必须根据日期添加分区

HiveOperator(task_id='add_partition_{}'.format(state),
             hql='alter table my_db.state_wise_records add partition (event_date="{{ ds }}", state="{state}") location "/user/cloudera/state_wise_records/event_date={{ ds }}/state={state}"'.format(state=state),
             dag=dag)
然而,这并不是将宏转换为日期,而不是像下面这样

/user/cloudera/state_wise_records/event_date={ds}/state=UP

这里有什么问题?

不能将带参数的字符串与Jinja模板结合使用。您将不得不拆分为不同的字符串并连接它们。例如:

hql='alter table my_db.state_wise_records add partition(event_date=“{{ds}},'
+'state=“{state}”)'。格式(state=state)
+“location”/user/cloudera/state_wise_records/event_date={{{ds}}/”
+'state={state}'。格式(state=state)