通过where查询加入

时间:2018-11-15 02:27:01

标签: hive

我基本上想与具有所有可能日期的日历表与我的商店产品主列表进行交叉连接。但是,我想过滤一年(365天)后再加入主列表。

我正在尝试以下查询-

select * from ( select a.store_id,a.product_id from mez_2018_store_product_lst) a cross join
(select b.day_id,cast(to_date(from_unixtime(unix_timestamp(b.day_date, 'yyyy-MM-dd'))) as b.date from calendar where day_id>=20170101 and day_id<=20180101 ) b

而且我不断收到EOF错误。 你们可以帮忙吗?

1 个答案:

答案 0 :(得分:2)

尝试以下查询:

 hive> select * from 
 (select store_id,
    product_id from mez_2018_store_product_lst) a 
 cross join
(select day_id,
    to_date(from_unixtime(unix_timestamp(day_date, 'yyyy-MM-dd')))dt from calendar 
    where day_id>=20170101 and day_id<=20180101 ) b;