我有一个包含create table语句的HQL文件。
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运行时,我是获得解析异常
[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)。但是hive客户端没有任何问题
任何帮助将不胜感激
答案 0 :(得分:3)
使用以下选项之一:
... 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