Hive 1.1.0将表格分区类型从int更改为字符串 [英] Hive 1.1.0 Alter table partition type from int to string

查看:876
本文介绍了Hive 1.1.0将表格分区类型从int更改为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,它有一个int类型的分区,但我想要转换为字符串。但是,我无法弄清楚如何做到这一点。



表格描述为:

  Col1时间戳
Col2字符串
Col3字符串
Col4字符串
Part_col int

#分区信息
#col_name data_type注释

Part_col int

我创建的分区是Part_col = 0 ,Part_col = 1,...,Part_col = 23



我想将它们更改为Part_col ='0'等等



我在hive中运行这个命令:

  set hive.exec.dynamic.partitions = true; 
变更表tbl_name分区(Part_col = 0)Part_col Part_col字符串;

我也尝试使用partition(Part_col)一次更改所有分区。



我得到错误无效的列引用Part_col



我使用转换为十进制列,但无法弄清楚dec_column_name表示什么。



谢谢 解决方案

有点挖掘表明有一个配置单元 JIRA 有准确的更新分区列数据类型的命令( https://issues.apache.org/jira/browse/HIVE-3672

  alter table {table_name}分区列({column_name} {column_type}); 

根据 JIRA 执行了该命令,但显然它是从未在Hive Wiki中记录。



我在我的Hive 0.14系统上使用它,它按预期工作。


I have a table which has a partition of type int but which I want to convert to string. However, I can't figure out how to do this.

The table description is:

Col1 timestamp
Col2 string
Col3 string
Col4 string
Part_col int

# Partition information
# col_name data_type comment

Part_col int

The partitions I have created are Part_col=0, Part_col=1, ..., Part_col=23

I want to change them to Part_col='0' etc

I run this command in hive:

set hive.exec.dynamic.partitions = true;
Alter table tbl_name partition (Part_col=0) Part_col Part_col string;

I have also tried using "partition (Part_col)" to change all partitions at once.

I get the error "Invalid column reference Part_col"

I am using the example from https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types for conversion of decimal columns but can't figure out what dec_column_name represents.

Thanks

解决方案

A bit of digging revealed that there was a hive JIRA to have a command exactly for updating partition column data type (https://issues.apache.org/jira/browse/HIVE-3672)

alter table {table_name} partition column ({column_name} {column_type});

According to JIRA the command was implemented, but it's apparent that it was never documented on Hive Wiki.

I used it on my Hive 0.14 system and it worked as expected.

这篇关于Hive 1.1.0将表格分区类型从int更改为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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