Google bigquery 对2000亿条记录进行数据聚合和平均
记录开始于AVRO文件中,这些文件每天都使用以下模式创建。“attribute_key”和“attribute_value”记录中存储了20种不同的属性类型,每次测量中还包括时间戳和设备idGoogle bigquery 对2000亿条记录进行数据聚合和平均,google-bigquery,google-cloud-platform,google-cloud-dataflow,amazon-athena,bigdata,Google Bigquery,Google Cloud Platform,Google Cloud Dataflow,Amazon Athena,Bigdata,记录开始于AVRO文件中,这些文件每天都使用以下模式创建。“attribute_key”和“attribute_value”记录中存储了20种不同的属性类型,每次测量中还包括时间戳和设备id "fields" : [ {"type":"string", "name":"device_id"}, {"type":"string", "name":"record_date"}, {"type":"string", "name":"attribute_key"}, {"type":"string",
"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
我的问题是双重的
我需要创建一个表,其中包含所有时间收集的唯一设备ID,以及每个值类型的最新属性值
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天的平均值。(属性_3是采集样本的平均值)
我很好奇如何最好地承担这一点,我不知道从这里走到哪里。数据现在在bigquery中,我可以访问全套google clould工具。。。比如数据流,或者其他任何东西
数据最初位于S3存储桶中,因此我可以使用AWS上的任何解决方案对其进行处理
我只是不知道做这件事最明智的方法是什么。希望这些链接中的一些能帮助你。创建表 BigQueryWebUI 如何从查询(用户的博客文章)创建表。这一条建议您可以使用BQWebUI并指定一个目标表。我在官方文件中找不到,所以不确定这是否有效。如果没有,您需要设置API并编写一些代码,如上面的示例所示。
BigQuery SQL查询应该适合您想要做的事情。这种方法有问题吗?+一个是在BigQuery.BigQuery中用SQL破坏它,因为您不需要编写太多代码来进行基本聚合
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