Thanks Florin for your response.
But in the suggested approach, I'd have a concern. my partitioned table in 
course of time would hols 100ds of Terabytes of data. So every time when I'm 
loading my data from staging table intothe production partitioned table and 
UNION over the same would be way too expensive. 

Is there any other workaround you feel would be suitable in my case.

Thanks and Regards
Bejoy.K.S



________________________________
From: Florin Diaconeasa <[email protected]>
To: [email protected]; Bejoy Ks <[email protected]>
Sent: Tuesday, October 4, 2011 2:46 AM
Subject: Re: Hive Dynamic Partions - How to avoid overwrite


I would recommend doing the following SELECT:

INSERT OVERWRITE INTO TABLE <input_table>

SELECT * FROM

(
SELECT
 x,y,z
FROM <input_table>

UNION ALL

SELECT *
FROM <target_table>

) allTables;

Obviously, there are rules coming with UNION ALL, such as you need to name(user 
alias eventually) all the columns of each select. More on this on the hive wiki.

Florin


On Oct 3, 2011, at 5:02 PM, Bejoy Ks wrote:

Hi Experts
>    I'm intending to use hive dynamic partition approach on my current 
>business use case. What I have in mind for the design is as follows.
>-Load my incoming data into a non partitioned hive table (Table 1)
>
>-Load this data into partitioned hive table using Dynamic Partitions(Table 2)
>-Flush the data in Table1(Drop Table and Recreate the same)
>With this series of steps my data world be ready for mining.
>
>    This is going to a periodic process happening daily. When I searched 
>around I came across a concern with this approach, 'the partitions getting 
>overwritten'. 
>
>For example. Say my second table is partitioned based on Country and in my 
>first load, data is populated in the partition with country=USA. When the 
>second time my Dynamic Partition load/insert it is executed and the source 
>data again contains value with country=USA, in that case the data that is 
>already there in the partition be overwritten with the new ones. 
>
>Is my understanding right on this scenario? Also in such scenarios what would 
>be recommended approach to overcome this hurdle. Basically I want the existing 
>data in the partition to be preserved while new data is added on to. I can't 
>go ahead with the static partition approach because my data is huge and the 
>number of partitions are also petty large.  Has some one framed effective 
>solutions on such scenarios with Dynamic Partition insert approach? Can some 
>one guide me with a suitable approach with hive for such use cases?
>
>
>Thanks and Regards
>Bejoy.K.S
>
>
>

Reply via email to