在 Hive 上给Partition表插入数据时报如下错误
这个情况只在含有 partition 的表中导出时会出现,其他的表则没有遇到
hive> LOAD DATA LOCAL INPATH '/home/v/Practises/07-Hive/practices/ml-latest-small/2008-08.data' OVERWRITE INTO TABLE `rating_table_part` partition(ts='2008-08');
Loading data to table default.rating_table_part partition (ts=2008-08)
Failed with exception MetaException(message:For direct MetaStore DB connections, we don't support retries at the client level.)
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask
网上查阅资料后,发现是 MySQL 中 Hive元数据的数据库的字符集有问题,需要修改成 latin1的
ref:https://www.cnblogs.com/bianqi/p/6953570.html
解决方法如下
mysql> show create database `HiveV122`;
+----------+----------------------------------------------------------------------+
| Database | Create Database |
+----------+----------------------------------------------------------------------+
| HiveV122 | CREATE DATABASE `HiveV122` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+----------+----------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> ALTER DATABASE `HiveV122` CHARACTER SET latin1;
Query OK, 1 row affected (0.04 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)