---
title: "hive 分通总结"
author: "乡里伢崽"
date: "2014-08-27T08:42:15Z"
tags: []
categories: ["编程语言"]
slug: "hive"
draft: false
lastmod: "2014-08-27T09:03:18Z"
id: 2109380
url: "https://crazymatrix.iteye.com/blog/2109380"
---

总结分析:

1. 定义了桶，但要生成桶的数据，只能是由其他表通过insert into 或是insert overwrite ，若表有分区只能使用insert overwrite 

2. 定义桶可以使用整型字段或是string类型字段

3.  若表没有定义桶也可以进行随机抽样

4. 必须先set hive.enforce.bucketing = true才可以将数据正常写入桶中，　若没有使用hive.enforce.bucketing属性, 则需要设置和分桶个数相匹配的reducer个数, 同时SELECT后添加CLUSTER BY