如何强制 Airflow 不要在 PostgresOperator 中将呈现的名称用单引号引起来?

How to force Airflow not to put single quotes around rendered name in PostgresOperator?

我正在使用带参数 parameters 的 Airflow PostgresOperator,以便将我的 sql 查询的 table 名称替换为我的字典中包含的名称。例如:

create_table = PostgresOperator(sql='DROP TABLE if exists %(my_table)s;',
                                parameters={'my_table':'my_name'},...)

问题是当运算符被执行时,呈现的 sql 是 DROP TABLE if exists 'my_name' 而不是预期的 DROP TABLE if exists my_name (当然这个操作失败了)。

如何强制 Airflow 不在呈现的名称周围加上单引号?

尝试使用 params 而不是 parameters,应该可行,因为 sqlPostgresOperator.

中声明为模板化字段
create_table = PostgresOperator(sql="DROP TABLE if exists {{ params.my_table }};",
                                params={'my_table':'my_name'},...)

我还没有测试过,但是providers-package documentation中有一个类似的用例。