Hive分割槽表匯入資料

2021-10-22 23:54:27 字數 1432 閱讀 1657

在hive上建立乙個簡單的分割槽表:

create table `school_student_info`(

`name` string,

`age` int,

`***` string

)partitioned by (`grade` string,

`teacher` string)

row format serde

'org.apache.hadoop.hive.serde2.lazy.lazy******serde'

with serdeproperties (

'field.delim'=',',

'serialization.format'=',',

'serialization.null.format'='');

hive引數說明:

1、 靜態插入資料

insert overwrite table school_student_info partition(grade=』three』,teacher=』li』)

select name,age,***,grade,teacher from table_old where grade=』three』 and teacher=』li』

要保證select中的字段個數和位置與插入的分割槽表的字段個數和位置對應。否則匯報如下錯誤:

failed: semanticexception [error 10044]: line 1:23 cannot insert into target table because column number/types are different 『symbol』: table insclause-0 has 4 columns, but query has 5 columns.

2、 動靜態混合分割槽插入

insert overwrite table school_student_info partition(grade=』three』,teacher)

select name,age,***,teacher from table_old where grade=』three』 and teacher=』li』

3、 動態分割槽插入

insert overwrite table school_student_info partition(grade,teacher)

select name,age,***,grade,teacher from table_old where grade=』three』 and teacher=』li』

grade和teacher根據select返回記錄的相對位置進行取值,

hive 非分割槽表 匯入csv資料

示例1 use temp drop table tmp cuiwei main recommend create table if not exists tmp cuiwei main recommend sml sa id int,sml set time int,sml cancel time ...

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...

hive分割槽表

partition對應於資料庫的 partition 列的密集索引 在 hive 中,表中的乙個 partition 對應於表下的乙個目錄,所有的 partition 的資料都儲存在對應的目錄中 例如 test表中包含 date 和 city 兩個 partition 則對應於date 201302...