Hive注释中文乱码
创建表的时候,comment说明字段包含中文,表成功创建之后,中文说明显示乱码
create external table movie(
userID int comment '用户ID',
movieID int comment '电影ID',
rating int comment '电影评分',
timestamped bigint comment '评分时间戳',
movieName string comment '电影名字',
movieType string comment '电影类型',
sex string comment '性别',
age int comment '年龄',
occupation string comment '职业',
zipcode string comment '邮政编码'
) comment '影评三表合一'
row format delimited fields terminated by ","
location '/hive/movie';
1.进入数据库Metastore中执行以下5条SQL语句
(1)修改表字段注释和表注释
alter table COLUMNS_V2 modify column COMMENT varchar(256) character set 'utf8';
alter table TABLE_PARAMS modify column PARAM_VALUE varchar(4000) character set 'utf8';
(2)修改分区字段注解
alter table PARTITION_PARAMS modify column PARAM_VALUE varchar(4000) character set 'utf8' ;
alter table PARTITION_KEYS modify column PKEY_COMMENT varchar(4000) character set 'utf8';
(3)修改索引注解
alter table INDEX_PARAMS modify column PARAM_VALUE varchar(4000) character set 'utf8';
修改metastore连接的URL
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hivedb?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>Root123456+</value>
</property>
</configuration>
验证
drop table movie;
原文地址:https://www.cnblogs.com/shine-rainbow/p/11386187.html
时间: 2024-11-02 06:32:34