HIVE: HDFS分区后创建的空桶



我正在尝试使用HIVE创建分区和桶。

用于设置一些属性:

set hive.enforce.bucketing = true;
SET hive.exec.dynamic.partition = true;
SET hive.exec.dynamic.partition.mode = nonstrict;
下面是创建表的代码:
CREATE TABLE transactions_production
( id string,
dept string,
category string,
company string,
brand string,
date1 string,
productsize int,
productmeasure string,
purchasequantity int,
purchaseamount double)
PARTITIONED BY (chain string) clustered by(id) into 5 buckets
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS TEXTFILE;

下面是插入数据到表中的代码:

INSERT OVERWRITE TABLE transactions_production PARTITION (chain)
select id, dept, category, company, brand, date1, productsize, productmeasure,
purchasequantity, purchaseamount, chain from transactions_staging;

在HDFS中创建分区和桶,但是数据只存在于所有分区的第一个桶中;所有剩余的桶都是空的

请让我知道我做错了什么以及如何解决这个问题。

当使用bucket时,Hive会根据值(这里您使用id)对表进行散列,并将表拆分为分区内的许多平面文件。

因为表是由id的散列分割的,所以每次分割的大小是基于表中的值。

如果没有值可以映射到第一个桶以外的桶,那么所有这些平面文件将为空。

最新更新