2016-09-20 76 views
2

兩列的表分區我有兩列在蜂房

id value 
abc 11 
xyz 12 
pqr 11 
mno 13 
pqr 12 
stu 13 
wxy 11 

我具有由配置單元或SQL查詢分區這個表是根據「值」的表。

+0

我得到了在蜂巢表分區的一些文檔,但它不工作了兩列的表。 – SiD

+0

ALTER TABLE table1 PARTITION BY KEY(id,value)PARTITIONS 2;' –

+0

@ Dev.Joel錯誤'ParseException行1:21無法識別alter table語句中的''KEY'附近的'PARTITION''的輸入(state = 42000 ,code = 40000)' – SiD

回答

1
SET hive.exec.dynamic.partition.mode=nonstrict; 
SET hive.exec.dynamic.partition=true; 


create table table (id string) partitioned by (value string) stored as ORC tblproperties ("orc.compress" = "SNAPPY"); 

INSERT INTO table1 PARTITION (value) 
select * from table where value is not NULL; 
+0

是其作品,但要記住很多。 – SiD

+0

它已經有SNAPPY比較 –

1

探索後,我得到了答案。

create table table (id string) partitioned by (value string) stored as ORC tblproperties ("orc.compress" = "SNAPPY"); 


SET hive.exec.dynamic.partition.mode=nonstrict; 
SET hive.exec.dynamic.partition=true; 

SET hive.exec.max.dynamic.partitions=2048; 
SET hive.exec.max.dynamic.partitions.pernode=256; 

INSERT INTO table1 PARTITION (value) 
select * from table where value is not NULL; 
+0

它需要大量的內存,還有人有更好的解決方案,所以請給它 – SiD

+0

刪除這兩個屬性SET hive.exec.max.dynamic.partitions = 2048; SET hive.exec.max .dynamic.partitions.pernode = 256'這不是需要。 –