这些记录是在AVRO文件中开始的,这些文件每天都使用以下模式创建。在"attribute_key“和"attribute_value”记录中存储了20种不同的属性类型,时间戳和device_id也包含在每个度量中。
"fields" : [
{"type":"string", "name":"device_id"},
{"type":"string", "name":"record_date"},
{"type":"string", "name":"attribute_key"},
{"type":"string", "name":"attribute_value"}]
我已经能够获取每日文件并将它们加载到bigquery中按月分隔的表中。
device_attributes201501
device_attributes201502
device_attributes201503
device_attributes201504
device_attributes201505
device_attributes201506
device_attributes201507
device_attributes201508
device_attributes201509
device_attributes201510
device_attributes201511
device_attributes201512
我的问题是双重的,
我需要创建一个表,其中包含所有时间收集的所有唯一device_ids,以及每个值类型的最新属性值。
device_id, record_date, attribute_key, attribute_value
abc123 2015-10-11 attribute_1 5
abc123 2015-11-11 attribute_1 5
abc123 2015-12-11 attribute_1 10
abc123 2015-10-11 attribute_1 0
abc456 2015-10-11 attribute_1 0
abc789 2015-10-11 attribute_1 0
abc123 2015-11-11 attribute_1 0
abc456 2015-11-11 attribute_1 0
abc789 2015-11-11 attribute_1 6
abc123 2015-10-11 attribute_2 blue
abc123 2015-11-11 attribute_2 red
abc123 2015-12-11 attribute_2 red
abc456 2015-12-11 attribute_2 blue
abc789 2015-12-11 attribute_2 green
对于某些属性,还需要计算每周、每月和90天的平均值。(attribute_3为采集样本的平均值)
device_id, last_update, attribute_1, attribute_2
abc123 2015-12-11 6 red
abc456 2015-12-11 0 blue
abc789 2015-12-11 3 green
我很好奇如何最好地接受这件事,但我不知道接下来该怎么做。数据现在在bigquery中,我可以访问全套google clould工具……就像数据流,或者其他任何东西。
数据最初是在一个S3存储桶中,所以我可以使用亚马逊网络服务上的任何解决方案来处理它。
我只是不知道怎么做才是最聪明的。
发布于 2017-02-22 09:47:48
希望这些链接能对你有所帮助。创建表https://cloud.google.com/bigquery/docs/tables#creating-a-table
BigQuery Web UI https://cloud.google.com/bigquery/bigquery-web-ui
如何从查询(用户的博客帖子)创建表。这个建议您可以使用BQ WebUI并指定一个目标表。我在官方文档中找不到这一点,所以不确定这是否有效。如果没有,您将需要设置API并编写一些代码,如上面的示例所示。https://chartio.com/resources/tutorials/how-to-create-a-table-from-a-query-in-google-bigquery/
https://stackoverflow.com/questions/42357424
复制相似问题