etl - 如何防止记录加密的气流变量?
问题描述
我已经设置了一个声明了加密变量的气流。我正在使用BigQueryOperator。我在提供给类的 SQL 中使用加密变量。但气流在解密变量后记录 SQL。我怎样才能防止这种情况发生?
解决方案
不幸的是,没有内置的方法来实现这一点。
一种可能的解决方法是删除self.log.info('Executing: %s', self.sql)
line inBigQueryOperator
或创建一个新的 Operator 继承BigQueryOperator
,如下所示:
class CustomBQOperator(BigQueryOperator):
@apply_defaults
def __init__(self, *args, **kwargs):
super(CustomBQOperator).__init__(*args, **kwargs)
def execute(self, context):
if self.bq_cursor is None:
hook = BigQueryHook(
bigquery_conn_id=self.bigquery_conn_id,
use_legacy_sql=self.use_legacy_sql,
delegate_to=self.delegate_to)
conn = hook.get_conn()
self.bq_cursor = conn.cursor()
self.bq_cursor.run_query(
self.sql,
destination_dataset_table=self.destination_dataset_table,
write_disposition=self.write_disposition,
allow_large_results=self.allow_large_results,
flatten_results=self.flatten_results,
udf_config=self.udf_config,
maximum_billing_tier=self.maximum_billing_tier,
maximum_bytes_billed=self.maximum_bytes_billed,
create_disposition=self.create_disposition,
query_params=self.query_params,
labels=self.labels,
schema_update_options=self.schema_update_options,
priority=self.priority,
time_partitioning=self.time_partitioning,
api_resource_configs=self.api_resource_configs,
cluster_fields=self.cluster_fields,
)
然后用这个CustomBQOperator
代替BigQueryOperator
推荐阅读
- python - 创建一个带有到期日期的“临时”文件
- azure-devops - 如何使用 Azure Devops 中的 Azure Devops API 在 C# 中创建/更新具有父子关系的工作项
- java - Liferay 中用于访问邮件的服务器错误
- c# - 将子类与父类列表区分开来
- python-3.x - 在 tkinter 窗口中显示标签后,我无法弄清楚如何重置标签
- excel - 我正在寻找一个代码,它在 A 列的值为 x 的行中选择指定范围
- c# - 检查两个对象之间是否所有属性(除了两个)是否匹配的干净方法?
- reactjs - 在 React JS 中将 props / state 传回父组件
- angularjs - 在更改 ng-model 值时应该更改
- sql-server - 如何通过给出函数名称,特定字母,下一个字母来使用sql server中的函数在一个特定字母之后选择下n个字母