每当我需要挂载分区时,我都需要运行它。而不是我手动执行它有一种方法来自动检测外部配置单元表中的分区
ALTER TABLE TableName ADD IF NOT EXISTS PARTITION()location 'locationpath';
答案 0 :(得分:1)
答案 1 :(得分:0)
使用动态分区,不需要手动创建目录。但是动态分区模式需要设置为nonstrict,默认情况下是严格的
CREATE External TABLE profile (
userId int
)
PARTITIONED BY (city String)
location '/user/test/profile';
set hive.exec.dynamic.partition.mode=nonstrict;
hive> insert into profile partition(city)
select * from nonpartition;
hive> select * from profile;
OK
1 Chicago
1 Chicago
2 Orlando
和HDFS
[cloudera@quickstart ~]$ hdfs dfs -ls /user/test/profile
Found 2 items
drwxr-xr-x - cloudera supergroup 0 2016-08-26
22:40 /user/test/profile/city=Chicago
drwxr-xr-x - cloudera supergroup 0 2016-08-26
22:40 /user/test/profile/city=Orlando