Hive 配置单元视图查询未使用分区
我有蜂巢表和表上的视图。在使用where子句对分区列执行表查询时,我从explain中看到查询使用的是分区列。但在视图上运行相同的查询时,从解释计划中可以看出分区键并没有使用。 请建议 示例代码在这里,视图是在where子句Select*from where code='XX'中按国家代码过滤的所有列的表上创建的 用于表的查询Hive 配置单元视图查询未使用分区,hive,explain,Hive,Explain,我有蜂巢表和表上的视图。在使用where子句对分区列执行表查询时,我从explain中看到查询使用的是分区列。但在视图上运行相同的查询时,从解释计划中可以看出分区键并没有使用。 请建议 示例代码在这里,视图是在where子句Select*from where code='XX'中按国家代码过滤的所有列的表上创建的 用于表的查询 SELECT a.unique_id, a.country_code, a.rpt_prd, a.abv_cut_off_scor_flag, a.acc
SELECT a.unique_id,
a.country_code,
a.rpt_prd,
a.abv_cut_off_scor_flag,
a.acct_und_promo_flag,
.
.
b.arrg_cob_dt,
b.arrg_id
from
a
inner join
b
on a.country_code = b.country_code
and a.product_code = b.product_code
and a.rpt_prd =b.rpt_prd
and a.unique_id =b.unique_id
and a.arrg_id = b.arrg_id
WHERE a.country_code='XX'
AND a.product_code = 'YYYYY'
AND a.rpt_prd ='20171231' ;
a
======================================
Partition Key for - a
PARTITIONED BY ( |
| `country_code` string, |
| `product_code` string, |
| `rpt_prd` string, |
| `unique_id` string)
b
=======================================
PARTITIONED BY ( |
| `country_code` string, |
| `product_code` string, |
| `rpt_prd` string, |
| `unique_id` string)
Query using Views:
===================
SELECT a.unique_id,
a.country_code,
a.rpt_prd,
a.abv_cut_off_scor_flag,
a.acct_und_promo_flag,
.
.
b.arrg_cob_dt,
b.arrg_id
from
a
inner join
b
on a.country_code = b.country_code
and a.product_code = b.product_code
and a.rpt_prd =b.rpt_prd
and a.unique_id =b.unique_id
and a.arrg_id = b.arrg_id
WHERE a.country_code='XX'
AND a.product_code = 'YYYYY'
AND a.rpt_prd ='20171231' ;
由于视图使用与实际表相同的基础数据,因此它应该使用分区。也就是说 一种可能的解决方法是通过创建如下语法使视图明确地知道分区:
ALTER VIEW view_name ADD PARTITION (partition_col = column_name)
您应该添加一些代码…添加视图创建脚本和查询。。