gpt4 book ai didi

hadoop - SQL 中的动态聚合 (Hive)

转载 作者:可可西里 更新时间:2023-11-01 16:36:20 24 4
gpt4 key购买 nike

我有两张 table 。表 A 有 3 列:用户标识、开始日期和结束日期。带有事件和日期时间戳的表 B。我想根据表 A 将表 B 汇总到开始日期和结束日期之间的日期时间。所以类似...

select a.userid, count(distinct b.eventid) as events
from table a
inner join table b
on a.userid=b.userid
and b.datetime between a.starttime and b.endtime
group by a.userid

但 Hive 不喜欢那样...我正在使用 Hadoop HortonWorks。非常感谢任何指导!

最佳答案

between 条件移至 where,因为在 2.2.0 版本之前仅支持 join 中的相等条件。

From Hive documentation

Complex expressions in ON clause are supported, starting with Hive 2.2.0 (see HIVE-15211, HIVE-15251). Prior to that, Hive did not support join conditions that are not equality conditions.

关于hadoop - SQL 中的动态聚合 (Hive),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51957137/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com