是否可以在HIVE中更改分区元数据? [英] Is it possible to change partition metadata in HIVE?

查看:105
本文介绍了是否可以在HIVE中更改分区元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我之前提出的问题的扩展:如何比较具有不同数据类型组的两列

This is an extension of a previous question I asked: How to compare two columns with different data type groups

我们正在探索更改表中元数据的想法,而不是执行CAST操作SELECT语句中的数据。更改MySQL Metastore中的元数据非常容易。但是,是否有可能将元数据更改应用于分区(它们是每天的)?否则,当历史记录为STRING时,我们可能会陷入当前和将来的数据类型为BIGINT的问题。

We are exploring the idea of changing the metadata on the table as opposed to performing a CAST operation on the data in SELECT statements. Changing the metadata in the MySQL metastore is easy enough. But, is it possible to have that metadata change applied to partitions (they are daily)? Otherwise, we might be stuck with current and future data being of type BIGINT while the historical is STRING.

问题:是否可以在HIVE中更改分区元数据?如果是,怎么办?

Question: Is it possible to change partition meta data in HIVE? If yes, how?

推荐答案

您不能在配置单元中更改分区列实际上配置单元不支持更改分区列

You can not change the partition column in hive infact Hive does not support alterting of partitioning columns

引用:更改分区列的类型Hive

您可以这样想
-Hive通过在hdfs中创建一个分区列值为
的文件夹来存储数据-因为如果您尝试更改配置单元分区,则意味着您正在尝试更改配置单元表的整个目录结构和数据,如果按年份进行分区,则不可能
exp,这就是目录结构的样子

You can think of it this way - Hive stores the data by creating a folder in hdfs with partition column values - Since if you trying to alter the hive partition it means you are trying to change the whole directory structure and data of hive table which is not possible exp if you have partitioned on year this is how directory structure looks like

tab1/clientdata/2009/file2
tab1/clientdata/2010/file3

如果要更改分区列,可以执行以下步骤

If you want to change the partition column you can perform below steps


  1. 使用分区列中的所需更改创建另一个配置单元表

  1. Create another hive table with required changes in partition column

创建表new_table(A int,B String .....)

Create table new_table ( A int, B String.....)

从上一张表中加载数据

插入new_table分区(B)从表Prev_table

Insert into new_table partition ( B ) select A,B from table Prev_table

这篇关于是否可以在HIVE中更改分区元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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