0
votes

I have two hive tables.

Source table is partitioned by month. So the partition column is like below.

event_column, partition_month
2021-10-25 00:48:36.0, 2020-10
2021-11-18 00:46:36.0, 2020-11
2021-12-20 00:42:34.0, 2020-12

Destination table is partitioned by week. Destination table has the partition column in below format

partition_week
2021-11-07
2021-11-14
2021-11-21

I want to load last 6 months data using the above two columns in where clause. Could anyone please help me.

1
how week should be represented? - leftjoin
It is represented in yyyy-mm-dd - psais

1 Answers

1
votes

one option is to derive the partition week column based on the event_column. select next_day(date_sub(to_date('2021-11-18 00:46:36.0'),7),'SUN') which will give you 2021-11-14.You can then use this column while writing to the destination table.

Courtesy: How to get the Date of the first day of a week given a time stamp in Hadoop Hive? @Régis ARCHAMBAULT