繁体   English   中英

无论如何要更改外部配置单元表的非分区列的数据类型?

[英]Is there anyway to change the datatype of the non-partition column of the external hive table?

我正在尝试更改作为分区表的外部配置单元表的非分区列的数据类型?

例如,我有一个名为trans的分区表,其中有 5 列。 交易(数据类型 = 字符串)、产品(数据类型 = 字符串)、数量(数据类型 = 十进制(7,2))、年份(数据类型 = 整数)、周(数据类型 = 整数)、日期(数据类型 =日期)

trans 表是外部的,按年、周、日分区。

现在我必须将数量的数据类型从十进制(7,2)更改为十进制(15,2)。 我们怎么做? 我不想用更新的数据类型重新处理整个表。 是否有任何直接查询或命令来实现这一点?

我确实使用了命令/查询:

ALTER TABLE trans CHANGE quantity quantity decimal(15,2);

但这正在更改配置单元元存储中元数据的数据类型,而不是数据级别,这意味着在 Parquet 文件中,它不会更改数据类型,因为当我尝试从 spark 中选择数量列时,我遇到了下面提到的错误。

Py4JJavaError: An error occurred while calling o108.showString. 
org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 2.0 failed 10 times, most recent failure: Lost task 0.9 in stage 2.0 : java.lang.UnsupportedOperationException: org.apache.parquet.column.values.dictionary.PlainValuesDictionary$PlainIntegerDictionary

有一个大致相同的 Jira: HIVE-6784 - parquet-hive 应该允许列类型更改

由于性能影响,它以Won't Fix resolution 关闭,请阅读 Jira 评论以了解更多详细信息。

解决方案是create another table, insert overwrite from original table, then remove original table and rename new table

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM