0

记录开始于每天使用以下模式创建的 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_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 天的平均值。(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 中,我可以访问全套谷歌云工具......比如数据流或其他任何东西。

数据最初位于 S3 存储桶中,因此我可以使用 AWS 上的任何解决方案对其进行处理。

我只是不知道最聪明的方法是什么。

4

1 回答 1

1

希望其中一些链接对您有所帮助。创建表 https://cloud.google.com/bigquery/docs/tables#creating-a-table

BigQuery 网页界面 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/

于 2017-02-22T01:47:48.453 回答