Question

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

Was it helpful?

Solution

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"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top