Hive動態分割槽使用

2021-09-26 06:59:49 字數 1243 閱讀 7169

動態分割槽可以即時給表新增分割槽,不用通過修改sql實現。

允許在插入的時候指定分割槽,分割槽欄位為插入時字段的位置決定。

例如:

from page_view_stg pvs

insert overwrite table page_view partition

(dt=

'2008-06-08'

, country)

select pvs.viewtime, pvs.userid, pvs.page_url, pvs.referrer_url,

null

,null

, pvs.ip, pvs.cnt

其中country分割槽為pvs.cnt欄位。

配置引數

預設值含義

hive.exec.max.dynamic.partitions.pernode

100每個map或reduce允許建立的最大分割槽個數

hive.exec.max.dynamic.partitions

1000

允許建立的最大動態分割槽數

hive.exec.max.created.files

100000

可建立的最大檔案個數

hive.exec.dynamic.partition.mode

strict

strict需要有靜態分割槽字段,nonstrict允許所有分割槽都是動態的

hive.exec.dynamic.partition

false

是否開啟動態分割槽

hive.error.on.empty.partition

false

是否拋異常,如果動態分割槽結果為空

靜態分割槽需要在建表時指定分割槽字段,例如:

create

table page_view(viewtime int

, userid bigint

, page_url string, referrer_url string,

ip string comment

'ip address of the user'

)comment

'this is the page view table'

partitioned by

(dt string, country string)

stored as sequencefile;

建立分割槽dt和country。

Hive 動態分割槽使用

hive 動態分割槽與靜態分割槽,靜態分割槽需要制定分割槽欄位的值插入分割槽資料,動態分割槽可以根據分割槽欄位的值自動插入對應分割槽 靜態分割槽 須指定分割槽欄位的值 insert overwrite table test.tmp edw customer event detail di parti...

Hive 動態分割槽的使用

set hive.exec.dynamic.partition true set hive.exec.dynamic.partition.mode nonstrict 預設是strict嚴格模式,至少要有乙個靜態分割槽。將下表按照location進行分割槽 建立分割槽表 create table d...

HIVE動態分割槽

一 前段時間因為導表需求 從一張表中查詢出資料,按日期分割槽overwrite 到指定分割槽表中 在hive裡面研究了一下自動分割槽。步驟 1 建好所需分割槽表 2 設定分割槽引數?1 2 3 4 sethive.exec.dynamic.partition true 可通過這個語句檢視 sethi...