1. 程式人生 > 其它 >指定動態分割槽_hive分割槽表

指定動態分割槽_hive分割槽表

技術標籤:指定動態分割槽

1. 建立分割槽表

create external table if not exists table1(col1 string,col2 string)partitioned by (state string,country string)row format delimited fields terminated by ',' store as ORC;

2. 分割槽表中插入資料

2.1. 靜態分割槽表

靜態分割槽表在向表中插入資料時要指定對應分割槽

INSERT OVERWRITE table1 (state='Asia', month='China') 
SELECT col1, col2 FROM table2;

2.2 動靜結合分割槽表

啟動動態分割槽功能set hive.exec.dynamic.partition=true;
設定動態分割槽表中至少有一個分割槽為靜態分割槽set hive.exec.dynamic.partition.mode=strick;

INSERT OVERWRITE table1(state='Asia', country)SELECTcol1, col2FROM table2;

2.3. 完全動態分割槽表

啟動動態分割槽功能set hive.exec.dynamic.partition=true;
允許全部分割槽都是動態分割槽set hive.exec.dynamic.partition.mode=nostrick;

INSERT OVERWRITE table1(state, country)SELECT col1, col2FROM table2;

3.分割槽表相關引數

set hive.exec.max.dynamic.partitions.pernode=100

--每個maper或reducer可以允許建立的最大動態分割槽個數,預設是100

set hive.exec.max.dynamic.partitions =1000

--動態分割槽的上限,預設1000

set hive.exec.max.created.files =10000

--一個mapreduce作業能建立的HDFS檔案最大數,預設是100000

dfs.datanode.max.xcievers

8192

--控制DataNode一次可以開啟的檔案個數

--這個引數必須設定在DataNode的$HADOOP_HOME/conf/hdfs-site.xml檔案中

33d1369f298ecfe7c4d5fb02f00b6d36.png