简体   繁体   中英

Hive partitioned view not showing partitions info

I have created a partitioned view in Hive as below

create view if not exists view_name
PARTITIONED ON(date)
as
select col1,col2,date
from table1
union all
select col1,col2,date
from table2

The underlying tables are partitioned on 'date' column. When I use DESCRIBE FORMATTED VIEW_NAME I could see the partitions information as null as showin in screenshot. enter image description here

If I use SHOW CREATE TABLE View_Name, I get view definition without partitions as below

create view if not exists view_name
as
select col1,col2,date
from table1
union all
select col1,col2,date
from table2

Please let me know what I am missing

From the hive documentation

Although there is currently no connection between the view partition and underlying table partitions, Hive does provide dependency information as part of the hook invocation for ALTER VIEW ADD PARTITION. It does this by compiling an internal query of the form

in the other words, there is no partition information available in the views about the underlying tables. A workaround (depending how complex is your view query) is add the partitions as follow

ALTER VIEW view_name ADD [IF NOT EXISTS] partition_spec partition_spec

At least from the user perspective, it will provide information about the available partitions in the underlying tables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM