配置单元添加分区语句忽略前导零 [英] hive add partition statement ignores leading zero

查看:109
本文介绍了配置单元添加分区语句忽略前导零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在hdfs上安装了文件夹

/ user / test / year = 2016 / month = 04 / dt = 25 / 000000_0



需要将此分区路径添加到测试表。



命令:

  ALTER TABLE测试ADD IF NOT EXISTS PARTITION(year = 2016,month = 04,dt = 25)

但是这个添加分区命令忽略了月份分区中的前导零,并在2016年内创建了一个额外的文件夹,当月= 4。
/ user / test / year = 2016 / month = 04 /
/ user / test / year = 2016 / month = 4 /
并且表将被指向 / user / test / year = 2016 / month = 4 / 不包含任何数据。

我检查了
WARN org.apache.hadoop.hive.ql的日志。 parse.BaseSemanticAnalyzer - Partition Spec month = 04已更改为month = 4



请让我知道是否有人遇到此类问题,如何避免这种情况?



Hive版本是:1.2.1000

解决方案

您正在使用整数类型的分区。如果您需要比使用字符串分区和引号的前导零: ALTER TABLE test ADD NOT IF NOT EXISTS PARTITION(year ='2016',month ='04',dt = '25')


I've folder on hdfs
/user/test/year=2016/month=04/dt=25/000000_0

Need to add this above partition path to a test table.

command :

ALTER TABLE test ADD IF NOT EXISTS PARTITION (year=2016,month=04,dt=25)

But this add partition command is ignoring the leading zero in the month partition and creates an extra folder inside 2016 as month=4. /user/test/year=2016/month=04/ /user/test/year=2016/month=4/ and table will be pointed to /user/test/year=2016/month=4/ this path which doesn't contain any data.

I've checked the logs which says WARN org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer - Partition Spec month=04 has been changed to month=4

Please let me know if anyone faced this kind of issue and how to avoid this?

Hive version is : 1.2.1000

解决方案

You are using integer type for partitions. If you need leading zeros than use string partitions and quotes: ALTER TABLE test ADD IF NOT EXISTS PARTITION (year='2016',month='04',dt='25')

这篇关于配置单元添加分区语句忽略前导零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆