Hive:动态分区

时间:2017-05-23 13:57:38

标签: hadoop hive

我尝试实施动态分区以更新最近30个分区中的日期:

set hive.exec.dynamic.partition=true;
insert overwrite tmp_ol.user_status_aggre partition(`day`)
select 
uuid,
uv+(case when b.uuid is not null then 1 else 0 end) as uv,
`date` as `day`
from 
(select uuid,uv,`date` from user_status_aggre where `day` between `2017-05-15` and `2017-05-22`) a
left join 
(select uuid from tabledemo where `day`='2017-05-22') b
on a.uuid=b.uuid

但是我收到了错误:

FAILED: ParseException line 1:17 cannot recognize input near 'tmp_ol' '.' 'user_status_aggre' in destination specification

创建表的查询如下:

create table tmp_ol.user_status_aggre (
uuid string,
uv string,
`date` date)
PARTITIONED BY (`day` string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001'
STORED AS textfile;

我想知道动态分区是否无法应用于自身。谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

尝试下面的一个:

SET hive.exec.dynamic.partition=true;
INSERT
    overwrite TABLE tmp_ol.user_status_aggre partition
    (
        day 
    )
SELECT
    uuid,
    uv+(
        CASE
            WHEN b.uuid IS NOT NULL
            THEN 1
            ELSE 0
        END) AS uv,
    date   AS day
FROM
    (
        SELECT
            uuid,
            uv,
            date
        FROM
            user_status_aggre
        WHERE
            day BETWEEN '2017-05-15' AND '2017-05-22') a
LEFT JOIN
    (
        SELECT
            uuid
        FROM
            tabledemo
        WHERE
            day='2017-05-22') b
ON
    a.uuid=b.uuid
相关问题