在配置单元中按时间间隔分组给出空输出
group by with interval of time in hive gives null output
我有一个数据集,如下所示-
Name Time
A 00:00:00
B 00:03:53
C 00:01:16
A 00:04:34
A 00:07:32
A 00:18:36
C 00:16:12
C 00:05:04
E 00:01:50
D 00:12:05
A 00:11:20
B 00:04:27
D 00:02:47
A 00:00:23
I 00:00:23
F 00:36:21
F 00:02:46
我正在尝试划分目的地,从 00.00.00 开始每 6 分钟间隔一次
所以我想出的蜂巢查询-
select name,count(1),FLOOR(UNIX_TIMESTAMP(time)/360) from csvlog GROUP BY name , FLOOR(UNIX_TIMESTAMP(time)/360) limit 10;
我得到的输出 -
A 1062 NULL
B 8 NULL
C 4 NULL
D 6 NULL
E 6 NULL
F 5 NULL
G 1 NULL
H 2 NULL
I 7 NULL
NULL 是值,我没想到。
我在 Hive 才 1 天,所以我可能做错了什么。
我期待时间作为一个价值。
我意识到如果我使用子字符串,那么一切正常-
select name,count(1),FLOOR(UNIX_TIMESTAMP(time)/360) from csvlog GROUP BY name , FLOOR(UNIX_TIMESTAMP(time)/360) limit 10;
replace
FLOOR(UNIX_TIMESTAMP(time)/360)
with
floor((floor(cast(substring(time,1,2) as int)*60 + cast(substring(time,4,2) as int)))/6)
或按照 GoBrewers 的建议
select name,count(1),FLOOR(UNIX_TIMESTAMP(time,'HH:mm:ss')/360) from csvlog GROUP BY name , FLOOR(UNIX_TIMESTAMP(time'HH:mm:ss')/360) limit 10;
我有一个数据集,如下所示-
Name Time
A 00:00:00
B 00:03:53
C 00:01:16
A 00:04:34
A 00:07:32
A 00:18:36
C 00:16:12
C 00:05:04
E 00:01:50
D 00:12:05
A 00:11:20
B 00:04:27
D 00:02:47
A 00:00:23
I 00:00:23
F 00:36:21
F 00:02:46
我正在尝试划分目的地,从 00.00.00 开始每 6 分钟间隔一次 所以我想出的蜂巢查询-
select name,count(1),FLOOR(UNIX_TIMESTAMP(time)/360) from csvlog GROUP BY name , FLOOR(UNIX_TIMESTAMP(time)/360) limit 10;
我得到的输出 -
A 1062 NULL
B 8 NULL
C 4 NULL
D 6 NULL
E 6 NULL
F 5 NULL
G 1 NULL
H 2 NULL
I 7 NULL
NULL 是值,我没想到。 我在 Hive 才 1 天,所以我可能做错了什么。 我期待时间作为一个价值。
我意识到如果我使用子字符串,那么一切正常-
select name,count(1),FLOOR(UNIX_TIMESTAMP(time)/360) from csvlog GROUP BY name , FLOOR(UNIX_TIMESTAMP(time)/360) limit 10;
replace
FLOOR(UNIX_TIMESTAMP(time)/360)
with
floor((floor(cast(substring(time,1,2) as int)*60 + cast(substring(time,4,2) as int)))/6)
或按照 GoBrewers 的建议
select name,count(1),FLOOR(UNIX_TIMESTAMP(time,'HH:mm:ss')/360) from csvlog GROUP BY name , FLOOR(UNIX_TIMESTAMP(time'HH:mm:ss')/360) limit 10;