-2

I have a table with date column and partition is made on that date column in hive . Say as of now 300 part files are there and each day only one record will insert then my table contains 300 records . Now I want to create a duplicate table with merging all the partition files into one . How can I do that Thanks in advance

Chinna
  • 1
  • 2
    This is not a coding service we area community that help each other to solve its issues, what have you tried? or what is your approach? can you post an example of your code or something meaningful? – Ricardo Gonzalez Oct 11 '19 at 13:45

1 Answers1

0

you can use compaction feature provided in hive

set hive.support.quoted.identifiers=none;
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;

    with partition_list as
    (
    select date, count(distinct input__file__name) cnt from table_name
    group by date having cnt > 0
    )
    insert overwrite table table_name partition (date)
    select * from table_name 
    where date in (select date from partition_list)
Strick
  • 1,512
  • 9
  • 15