hive创建分区表问题

今天在应用别人提供的新安装的hadoop集群环境时,创建Hive表成功却不能添加数据,不添加任何数据也不能查询。在网上找到这个帖子:

http://blog.csdn.net/chenyi8888/article/details/7165519 正好解决了我的问题,在此分享。

最近在使用hive的时候,metadata我是放在mysql(是5.5的版本)里的。

当时mysql设置的字符集是utf8,

正常创建表的时候,一切正常,当我进行创建分区表后,在使用的时候,就出现以下错误信息:

FAILED: Error in metadata: javax.jdo.JDODataStoreException: Error(s) were found while auto-creating/validating the datastore for classes. The errors are printed in the log, and are attached to this exception.
NestedThrowables:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Specified key was too long; max key length is 1000 bytes
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask


以上错误,主要是在select操作、drop操作时,就会出错。

这里提醒下,创建分区表,需要执行alter table 表名 add  PARTITION(stat_date='2011-06-08', province='ZheJiang')这样的SQL语句。

然后才能导入数据。不然就有如下报错信息:

FAILED: Error in semantic analysis: Line 3:10 Partition not found ''2011-12-30''

转回主题来,解决的方案:

是将mysql的数据库字符集设置成latin1,就行了(网上有很多修改字符集的操作,这里就不详细说了)。
修改数据库的字符集
    mysql>use mydb
    mysql>alter database mydb character set latin1;

发布了12 篇原创文章 · 获赞 5 · 访问量 24万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章