Hive 分区表
在hive中 創建一個表:
create external table track_info( ip string, country string, province string, city string, url string, time string, page string ) partitioned by (day string) row format delimited fields terminated by '\t' location '/project/trackinfo/';從HDFS中導入數據:load data inpath 'hdfs://swarm-worker1:9000/project/input/etl' overwrite into table track_info partition(day='2013-07-21');
因為我們使用分區,所以需要指定partition(day='2013-07-21')。
然后查看HDFS中的數據:
發現會自動根據我們的分區字段作為我們的目錄,進入到目錄day=2013-07-21:
執行查詢時,可以指定分區:
select count(1) from track_info where day='2013-07-21';這就會生成一個mapreduce運行。
總結
- 上一篇: Hive 内部表与外部表
- 下一篇: Hive将查询结果保存到另一张表中