且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从另一个表(包括配置单元中的分区列)创建临时表

更新时间:2023-11-23 08:54:52

这是源表xyz的问题,因为它包含分区__HIVE_DEFAULT_PARTITION__

This is a problem with source table xyz because it contains partition __HIVE_DEFAULT_PARTITION__

在动态分区模式下,插入的分区值为NULL时,Hive创建一个值为__HIVE_DEFAULT_PARTITION__的分区.

Hive creates a partition with value __HIVE_DEFAULT_PARTITION__ when in dynamic partition mode inserted partition value is NULL.

分区__HIVE_DEFAULT_PARTITION__与数字类型不兼容,这会导致错误,因为无法将其强制转换为数字类型.

Partition __HIVE_DEFAULT_PARTITION__ is not compatible with numeric type and this causing error because it cannot be cast to numeric type.

要删除或查询该分区,您需要先将列类型更改为字符串:

To remove or query this partition, you need to change the column type to string first:

ALTER TABLE xyz PARTITION COLUMN (col4 string);

当然,您可能需要备份表并检查数据,然后再删除并决定如何处理此数据.

Of course you may want to backup table and check the data before removing and decide what to do with this data.

要删除分区:

ALTER TABLE xyz DROP PARTITION (col4 = '__HIVE_DEFAULT_PARTITION__');

删除分区后,您可以将分区列的类型改回数字类型.

After removing partition you can change the type of partition column back to numeric type.