1. 程式人生 > >hive partition 分割槽詳解一

hive partition 分割槽詳解一

一.檢視分割槽命令

1.show partitions xxx

hive> show partitions xxx;
OK
day=20150908
day=20151020
day=20151021
day=20151022

...

day=20160318
Time taken: 0.139 seconds, Fetched: 144 row(s)

由此可見上述命令顯示了基本的分割槽情況

2.desc xxx partition(day=20160315

hive> desc xxx partition(day=20160315);
OK
list_time               string
cookie                  string
device_id               string
os                      string
device_brand            string
search_id               string
search_guid             string
...
filter                  string
day                     string

# Partition Information
# col_name                data_type               comment

day                     string
Time taken: 0.359 seconds, Fetched: 36 row(s)

此命令顯示了表結構與partition information

3.

hive>  desc extended ods_search_log_app partition(day=20160315);
OK
list_time               string
cookie                  string
device_id               string
os                      string
device_brand            string
search_id               string
search_guid             string
...
coupon                  string
filter                  string
day                     string

# Partition Information
# col_name                data_type               comment

day                     string

Detailed Partition Information    Partition(values:[20160315], dbName:xxx, tableName:xxx, ............. location:hdfs://mycluster/data/hive/warehouse/xxx/xxx/day=20160315, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=1}), bucketCols:[], sortCols:[], parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[], skewedColValueLocationMaps:{}), storedAsSubDirectories:false), parameters:{transient_lastDdlTime=1458083053})
Time taken: 0.369 seconds, Fetched: 38 row(s)

多了個Detailed Partition Information,最初使用這條命令的初衷,是查詢分割槽對應的location,使用這條命令可以找到