我正在尝试使用Hive执行类似下面的操作。如何将Hive中的列定义为子查询?这在Hive中可能吗?
hive -e "
select
distinct i.SearchListingID,
(select count(*)
from calls c
where c.ServiceID = i.SearchListingID
) as CallsCount
from Impressions i
where i.yyyymmdd = 20120401
limit 10" > ImpressionCalls.txt
Hive history file=/tmp/jd/hive_job_log_jd_201205222049_550931420.txt
失败:解析错误:第4:1行无法识别'select''count''附近的输入(''在表达式规范中
答案 0 :(得分:9)
Hive不支持相关子查询。 这样的事情呢? (我自己没有机会在Hive上验证这个查询)
select
i.SearchListingID,
count(*)
from
(
select
distinct i.SearchListingID as SearchListingID
from
Impressions i
where
i.yyyymmdd = 20120401
)i
join
calls c
on(c.ServiceID = i.SearchListingID)
limit 10