u0001 delimeter的直线问题

wtlkbnrh  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(471)

我有一个hql文件,其中包含一个create table语句。

CREATE TABLE IF NOT EXISTS employee ( eid int, name String,
salary String, destination String)
COMMENT 'Employee details'
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '^A'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE;

表的字段分隔符是/u0001(ctrl-a)。当我使用hive(hive-f)运行这个hql文件时,它工作得非常好。但是当我使用beeline运行时,我得到了parse异常

[cloudera@quickstart Desktop]$ beeline -u jdbc:hive2://quickstart:10000/default -n admin -d org.apache.hive.jdbc.HiveDriver -f createtable.hql 
Connecting to jdbc:hive2://quickstart:10000/default
Connected to: Apache Hive (version 1.1.0-cdh5.4.2)
Driver: Hive JDBC (version 1.1.0-cdh5.4.2)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://quickstart:10000/default> CREATE TABLE IF NOT EXISTS employenter code hereee ( eid int, name String,
0: jdbc:hive2://quickstart:10000/default> salary String, destination String)
0: jdbc:hive2://quickstart:10000/default> COMMENT 'Employee details'
0: jdbc:hive2://quickstart:10000/default> ROW FORMAT DELIMITED
0: jdbc:hive2://quickstart:10000/default> 'FIELDS TERMINATED BY '
0: jdbc:hive2://quickstart:10000/default> LINES TERMINATED BY '\n'
0: jdbc:hive2://quickstart:10000/default> STORED AS TEXTFILE;
Error: Error while compiling statement: FAILED: ParseException line 5:0 cannot recognize input near ''FIELDS TERMINATED BY '' 'LINES' 'TERMINATED' in serde properties specification (state=42000,code=40000)

似乎beeline shell无法正确解析不可打印字符(ctrl a)。但是配置单元客户端没有任何问题
任何帮助都将不胜感激

nfzehxib

nfzehxib1#

使用以下选项之一:

... fields terminated by '\001' (Octal)
... fields terminated by '1' (Decimal)
... fields terminated by '\u0001' (Hexadecimal)

请注意,有一个与unicode文本('\u0001')相关的错误,该错误在版本2.1中应该已修复,因此使用第3个选项在早期版本中不起作用。https://issues.apache.org/jira/browse/hive-13434

相关问题