【发布时间】:2017-07-06 07:40:42
【问题描述】:
我有这个架构(通过 DDL 为表和视图提供):
hive> create table t_realtime(cust_id int, name string, status string, active_flag int);
hive> create table t_hdfs(cust_id int, name string, status string, active_flag int);
hive> create view t_inactive as select * from t_hdfs where active_flag=0;
hive> create view t_view as select * from t_realtime union all select * from t_inactive;
如果我触发如下查询:
hive> select * from t_view where active_flag = 1;
理想情况下,此查询不应访问 t_inactive 视图或 t_hdfs,因为 t_inactive 的视图定义本身具有 active_flag = 0 并且查询谓词具有 active_flag = 1。但是,默认情况下,它不会消除此联合视图的 t_inactive 部分。
对于这样的蜂巢查询,有没有办法实现这一点?也许是一些配置单元优化器参数或提示?
【问题讨论】:
-
根据您的决定,“默认情况下,它不会消除此联合视图的 t_inactive 部分。”
标签: sql hadoop hive query-optimization