简体   繁体   English

配置单元分区视图未显示分区信息

[英]Hive partitioned view not showing partitions info

I have created a partitioned view in Hive as below 我在Hive中创建了一个分区视图,如下所示

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. 当我使用DESCRIBE FORMATTED VIEW_NAME我可以在屏幕截图中看到分区信息为空。 enter image description here 在此处输入图片说明

If I use SHOW CREATE TABLE View_Name, I get view definition without partitions as below 如果我使用SHOW CREATE TABLE View_Name,则会得到不带分区的视图定义,如下所示

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. 尽管当前在视图分区和基础表分区之间没有连接,但是Hive确实将依赖项信息作为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. 至少从用户角度来看,它将提供有关基础表中可用分区的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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