【发布时间】:2014-11-14 05:32:47
【问题描述】:
我希望获得我发送的消息数量的每日、每周和每月总和。大约有 500 种不同的消息类型。
我有以下表格:
Table name: messages
int message_type
BIGINT num_sent
string date
Table name: stats
int message_type
BIGINT num_sent_today
BIGINT num_sent_week
BIGINT num_sent_month
每天都会更新表格消息,其中包含今天日期的新行。我可以每天运行一个配置单元查询来更新stats 表吗?注意我无法通过直接使用WHERE date >= 30 days ago 查询消息表来获得运行计数,因为表太大了。我必须改为从表统计中添加/减去每日值。像这样的:
// pseudocode
// Get this table (call it table b) from table messages
int message_type
BIGINT num_sent_today
BIGINT num_sent_seven_days_ago
BIGINT num_sent_thirty_days_ago
// join b with table stats so that I can
// Set stats.num_sent_today = b.num_sent_today
// Set stats.num_sent_week = stats.num_sent_week + b.num_sent_today - b.num_sent_seven_days_ago
// Set stats.num_sent_month = stats.num_sent_month + b.num_sent_today - b.num_sent_thirty_days_ago
【问题讨论】:
标签: hadoop mapreduce hive hiveql