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

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

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

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

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

现在我必须将数量的数据类型从小数 (7,2) 更改为小数 (15,2)。我们怎样才能做到?我不想用更新后的数据类型重新处理整个 table。是否有任何直接查询或命令可以实现此目的?

我确实使用了 command/query:

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

但这改变了配置单元元存储中元数据的数据类型,但不是数据级别意味着在 Parquet 文件中它没有改变数据类型,因此当我尝试 select 数量列时从火花我得到下面提到的错误。

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 should allow column type change

由于性能影响,已以 Won't Fix 分辨率关闭,请阅读 Jira 评论了解更多详情。

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