How to drop partitions from hive views?

96 Views Asked by At

I have a partitioned view and I am trying to drop an existing partition from the view definition using hive CLI. However, when I try to drop a partition, it throws me the following error:

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. null

Here is my create statement for view:

CREATE or replace VIEW test_view (logrecordtype, datacenter, ts_date, gen_date)
PARTITIONED ON (ts_date, gen_date)
AS SELECT logrecordtype, datacenter, ts_date, gen_date from test_table1 where ts_date <= '20200720'
union all
select logrecordtype, datacenter, ts_date, gen_date from test_table2 where ts_date != '20200720';

The underlying tables test_table1, test_table2 are also partitioned by (ts_date, gen_date).

Drop partition command:

ALTER VIEW test_view DROP IF EXISTS PARTITION (ts_date = '20200720', gen_date = '2020072201')

I am able to add partitions and issue show partition on my view but drop partition fails.

My show partition command shows:

show partitions test_view;
ts_date=20200720/gen_date=2020072201
0

There are 0 best solutions below