Can External Tables in Hive Intelligently Identify Partitions?

I need to run this whenever I need to mount partition. Rather than me doing it manually is there a way to auto detect partition in external hive tables

ALTER TABLE TableName ADD IF NOT EXISTS PARTITION()location 'locationpath';

Answers


Recover Partitions (MSCK REPAIR TABLE)

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-RecoverPartitions(MSCKREPAIRTABLE)

MSCK REPAIR TABLE table_name;

partitions will be add automatically


Using dynamic partition, the directory does not need to be created manually. But dynamic partition mode needs to be set to nonstrict, by default it is strict

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

and in 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

Need Your Help

Android JSONObject becomes null when trying to send

java android json stream

When I'm trying to push a JSONObject over a data stream, and I've built the JSONObject properly, but then I try and publish it to the stream it is null.

unexpected output of size allocated by malloc in C

c memory-management malloc heap free

I have read that malloc actually allocates (required_size + 1) blocks of memory and it stores the size in the first block and the pointer to the second block is returned. This way free() knows how ...