我有這個模式(通過DDL表和視圖給出):Hive Optimizer在優化視圖查詢時考慮視圖定義嗎?
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部分」。 –