1

下面是我的 JSON 对象,用于 DLP API 调用,用于屏蔽 GCS 存储桶上 parquet 文件上的特定数据列。虽然 calli dlp.deidentify_content() 方法我必须将项目传递给它,但不确定如何传递镶木地板文件,我已经提到了镶木地板文件路径。

inspect_config = {
    'info_types': info_types,
    'custom_info_types': custom_info_types,
    'min_likelihood': min_likelihood,
    'limits': {'max_findings_per_request': max_findings},
}

actions = [{
    'saveFindings': {
        'outputConfig': {
            'table': {
                'projectId': project,
                'datasetId': 1,
                'tableId': "result1"
            }
        }
    }
}]
# Construct a storage_config containing the file's URL.
url = 'gs://{}/{}'.format(bucket, filename)

storage_config = {
    'cloud_storage_options': {
        'file_set': {'url': url}
    }
}
# Construct deidentify configuration dictionary
deidentify_config = {
    "recordTransformations": {
        "fieldTransformations": [
            {
                "fields": [
                    {
                        "name": "IP-address"
                    }
                ],
                "primitiveTransformation": {
                    "cryptoHashConfig": {
                        "cryptoKey": {
                            "transient": {
                                "name": "[TRANSIENT-CRYPTO-KEY-1]"
                            }
                        }
                    }
                }
            },
            {
                "fields": [
                    {
                        "name": "comments"
                    }
                ],
                "infoTypeTransformations": {
                    "transformations": [
                        {
                            "infoTypes": [
                                {
                                    "name": "PHONE_NUMBER"
                                },
                                {
                                    "name": "EMAIL_ADDRESS"
                                },
                                {
                                    "name": "IP_ADDRESS"
                                }
                            ],
                            "primitiveTransformation": {
                                "cryptoHashConfig": {
                                    "cryptoKey": {
                                        "transient": {
                                            "name": "[TRANSIENT-CRYPTO-KEY-2]"
                                        }
                                    }
                                }
                            }
                        }
                    ]
                }
            }
        ]
    }
}
# Call the API
response = dlp.deidentify_content(
    parent, inspect_config=inspect_config,
    deidentify_config=deidentify_config, item=item)

我想要完成的是屏蔽 GCS 存储桶上的 parquet 文件并屏蔽少数列,并将屏蔽的 parquet 文件存储为 BigQuery 表上的表。

4

1 回答 1

1

Parquet 文件目前被扫描为二进制对象,因为系统还没有智能地解析它们。在 V2 api 中,此处列出了支持的文件类型

您可以按照本指南中的说明将存储桶中的 parquet 文件加载到 bigquery 中,然后使用 DLP API 解析来自 bigquery的数据

于 2019-10-10T15:22:47.957 回答