hive创表中文字段报错:Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaExcepti

  • Post author:
  • Post category:其他




1、详细报错信息

ERROR : FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:Add request failed : INSERT INTO `COLUMNS_V2` (`CD_ID`,`COMMENT`,`COLUMN_NAME`,`TYPE_NAME`,`INTEGER_IDX`) VALUES (?,?,?,?,?) )

运行作业出现错误,请联系管理员:java.lang.reflect.InvocationTargetException
	at sun.reflect.GeneratedMethodAccessor409.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.dtwave.dipper.spi.plugin.impl.DefaultPluginExecutor.execute(DefaultPluginExecutor.java:26)
	at com.dtwave.dipper.executor.proxy.executor.TaskExecutor.run(TaskExecutor.java:75)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:Add request failed : INSERT INTO `COLUMNS_V2` (`CD_ID`,`COMMENT`,`COLUMN_NAME`,`TYPE_NAME`,`INTEGER_IDX`) VALUES (?,?,?,?,?) )
	at org.apache.hive.jdbc.HiveStatement.waitForOperationToComplete(HiveStatement.java:381)
	at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:260)
	at org.apache.hive.jdbc.HiveStatement.executeUpdate(HiveStatement.java:487)
	at com.dtwave.dipper.hive.Hive2TaskRunnerPlugin.handleSql(Hive2TaskRunnerPlugin.java:258)
	at com.dtwave.dipper.hive.Hive2TaskRunnerPlugin.doRun(Hive2TaskRunnerPlugin.java:216)
	at com.dtwave.dipper.spi.plugin.runner.BasicTaskRunnerPlugin.execute(BasicTaskRunnerPlugin.java:66)
	... 10 more

END-EOF-END-EOF



2、报错原因

  • 是因为创建hive表的时候有中文字段,虽然拿反引号引着,但是不起作用。
  • 这时候去看看hive的元数据存储表的COLUMNS_V2表

表结构:

mysql> show create table COLUMNS_V2;
| COLUMNS_V2 | CREATE TABLE `columns_v2` (
  `CD_ID` bigint(20) NOT NULL,
  `COMMENT` varchar(256) DEFAULT NULL,
  `COLUMN_NAME` varchar(767) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
  `TYPE_NAME` mediumtext,
  `INTEGER_IDX` int(11) NOT NULL,
  PRIMARY KEY (`CD_ID`,`COLUMN_NAME`),
  KEY `COLUMNS_V2_N49` (`CD_ID`),
  CONSTRAINT `COLUMNS_V2_FK1` FOREIGN KEY (`CD_ID`) REFERENCES `cds` (`CD_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |

表字段含义:

表字段 注释
CD_ID 字段信息ID
COMMENT 字段注释
COLUMN_NAME 字段名
TYPE_NAME 字段类型
INTEGER_IDX 字段顺序



3、解决办法

  • 连接存储hive的元数据的数据库
  • 修改COLUMN_NAME字段的编码值为utf8
mysql> show databases;
mysql> use hive ;
mysql> alter table COLUMNS_V2 modify column COMMENT varchar(256) character set utf8;
mysql> alter table COLUMNS_V2 modify column COLUMN_NAME varchar(256) character set utf8;



版权声明:本文为weixin_46122692原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。