【问题标题】:data aggregation and averaging on 200 billion records对 2000 亿条记录进行数据聚合和平均
【发布时间】:2017-07-10 11:47:50
【问题描述】:

记录开始于使用以下架构每天创建的 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 上的任何解决方案对其进行处理。

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

【问题讨论】:

  • BigQuery SQL 查询应该可以满足您的需求。您在使用这种方法时遇到过问题吗?
  • +one 用于在 BigQuery 中使用 SQL 粉碎它。
  • BigQuery 因为您无需编写太多代码即可进行基本聚合

标签: google-bigquery google-cloud-platform google-cloud-dataflow amazon-athena bigdata


【解决方案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/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-23
    • 2015-09-27
    • 2021-05-25
    • 1970-01-01
    • 1970-01-01
    • 2022-03-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多