【发布时间】:2018-07-31 21:00:40
【问题描述】:
这是我的输入文件的样子:
{"Id": 1, "Address": {"Street":"MG Road","City":"Pune"}}
{"Id": 2, "Address": {"City":"Mumbai"}}
{"Id": 3, "Address": {"Street":"XYZ Road"}}
{"Id": 4}
{"Id": 5, "PhoneNumber": 12345678, "Address": {"Street":"ABCD Road", "City":"Bangalore"}}
在我的数据流管道中,我如何动态确定每行中存在哪些字段以符合 BigQuery 表架构。
例如,在第 2 行中,Street 缺失。我希望 BigQuery 中列 Address.Street 的条目为 "N/A" 或 null,并且不希望管道因架构更改或丢失数据而失败。
在使用 Python 写入 BigQuery 之前,如何在我的数据流作业中处理此逻辑?
【问题讨论】:
-
您是否尝试在您的表中插入此类数据?根据我的经验(BQ 流式传输或 Avro,但不是 JSON),如果要插入的数据缺少某些列,并且 BQ 的 DDL 已将此列标记为 Nullable,则将插入该行并将缺少的列标记为 Null .
标签: python google-cloud-platform google-bigquery google-cloud-functions google-cloud-dataflow