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

2021-10-16 03:14:33 字數 1529 閱讀 2516

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;
靜態分割槽表在向表中插入資料時要指定對應分割槽

insert overwrite table1 (state='asia', month='china')select col1, col2from table2;
啟動動態分割槽功能set hive.exec.dynamic.partition=true;設定動態分割槽表中至少有乙個分割槽為靜態分割槽set hive.exec.dynamic.partition.mode=strick;

insert overwrite table1(state='asia', country)selectcol1, col2from table2;
啟動動態分割槽功能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檔案中

hive 動態分割槽表

注意 1 並不是都要建輔助表,因為是用load的方式載入資料,所以才要建 2 select 的時候,分割槽欄位要寫在最後面 使用動態分割槽表必須配置的引數 設定為true允許使用dynamic partition hive.exec.dynamic.partition 預設false 設定dynam...

Hive分割槽表,動態分割槽,分桶表

分割槽針對的是資料的儲存路徑 分桶針對的是資料檔案 對已經分好類的檔案匯入靜態分割槽 create table tb p order oid int dt string cost double partitioned by mot string,day string row format delim...

hive 分割槽表

partitioned by create table tb name name string partitioned by age int row format delimited fields terminated by t load data local inpath file path in...