我正在使用脚本将策略标签设置为 bigquery 列(例如名称列),但我不知道如何继续使用 Python 脚本回滚此更改
from google.cloud import bigquery
from google.cloud.bigquery.schema import SchemaField,PolicyTagList
client = bigquery.Client()
table_id = 'project_id.dataset_id.table_id'
policy_tags = PolicyTagList(names=["projects/<my_project_id>/locations/us/taxonomies/<taxonomy_id>/policyTags/<policy_tag_id>"])
table = client.get_table(table_id)
table.schema = [
SchemaField(
name="name",
field_type="STRING",
policy_tags=policy_tags
),
SchemaField(
name="age",
field_type="INT64"
)
]
table = client.update_table(table=table,fields=["schema"])
print(table.schema)
提前致谢!
我尝试使用policy_tags=None,但它不起作用(附加的策略不会从列中删除)
https://cloud.google.com/bigquery/docs/column-level-security#api_5
policy_tags = PolicyTagList(names="")
成功了!