user4119502
user4119502

Reputation:

dynamic partitioning a table in hive for a given column from existing table

"Details" table which contains Name, Age and Date columns.

create table Details(Name String,Age int, Date String)

row format delimited fields terminated by ','

stored as textfile;

Name Age Date

aa 11 2012-04-06

bb 12 2012-04-06

cc 13 2013-02-10

dd 14 2013-02-10

ee 15 2013-02-10

ff 16 2014-04-01

gg 17 2014-04-01

hh 18 2014-04-01

ii 19 2014-04-01

jj 20 2014-04-01

How to insert the data into "Person" table by dynamic partitioning using Date column from "Details" table.

In the above scenario it must contain 3 partitions with data as

2012-04-06

2014-04-01

2014-04-01

Upvotes: 0

Views: 458

Answers (1)

user4119502
user4119502

Reputation:

hive> create table Person (Name String,Age int) partitioned by (date string) row format delimited fields terminated by ',';

hive> insert into table Person partition(date) select name,age,date from Details;

Upvotes: 0

Related Questions