简体   繁体   中英

Is there an easy way to create a partitioned table from a managed table in Hive?

I have a managed table in hive that I would like to partitioned based one of its columns. is there an easy way to create a partitioned table from this managed table?

managed table a (s,d,f,g,h,j,k, key)

create table b as table a partitioned by key.

Thanks

You can do this by Dynamic partitioning:

Here is an example: I have some log data, that has fields

id, tdate, info I have created a dynamic partitioned table

CREATE TABLE log_partitioned(id STRING,  info STRING)
PARTITIONED BY ( tdate STRING) 

and then Load the data

FROM logs lg
INSERT OVERWRITE TABLE log_partitioned PARTITION(tdate)
SELECT lg.id, lg.info, lg.tdate
DISTRIBUTE BY tdate;

It will successfully loading the data by dynamic partitioning from managed table.

I found this tutorial very useful. Please refer to this " http://kickstarthadoop.blogspot.com/2011/06/how-to-speed-up-your-hive-queries-in.html "

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM