我正在安装Hadoop / Pig / Thrift / Hive。到目前为止,我已经完成了所有工作,但是当我创建一个包含Serde的表时,我遇到了一个问题。这实际上是来自Hive的官方文档的复制/粘贴。
谁能告诉我它有什么问题?
add jar /opt/hadoop/hive-0.11.0-bin/lib/hive-contrib-0.11.0.jar; CREATE TABLE apachelog ( host STRING, identity STRING, user STRING, time STRING, request STRING, status STRING, size STRING, referer STRING, agent STRING) ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe' WITH SERDEPROPERTIES ( "input.regex" = "([^]*) ([^]*) ([^]*) (-|\\[^\\]*\\]) ([^ \"]*|\"[^\"]*\") (-|[0-9]*) (-|[0-9]*)(?: ([^ \"]*|\".*\") ([^ \"]*|\".*\"))?", "output.format.string" = "%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s %9$s" ) STORED AS TEXTFILE;
我在执行此操作时遇到的错误是:
hadoop@ux03:~# hive -f queries/web_logs.hive Logging initialized using configuration in jar:file:/opt/hadoop/hive-0.11.0-bin/lib/hive-common-0.11.0.jar!/hive-log4j.properties Hive history file=/tmp/hadoop/hive_job_log_hadoop_4858@ux03_201306301457_1933691814.txt Added /opt/hadoop/hive-0.11.0-bin/lib/hive-contrib-0.11.0.jar to class path Added resource: /opt/hadoop/hive-0.11.0-bin/lib/hive-contrib-0.11.0.jar FAILED: Error in metadata: java.util.regex.PatternSyntaxException: Unclosed character class near index 104 ([^]*) ([^]*) ([^]*) (-|\[^\]*\]) ([^ "]*|"[^"]*") (-|[0-9]*) (-|[0-9]*)(?: ([^ "]*|".*") ([^ "]*|".*"))? ^ FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
答案 0 :(得分:1)
您的正则表达式中似乎缺少空格:
"input.regex" = "([^ ]*) ([^ ]*) ([^ ]*) (-|\\[[^\\]]*\\])
([^ \"]*|\"[^\"]*\") (-|[0-9]*) (-|[0-9]*)(?: ([^ \"]*|\"[^\"]*\")
([^ \"]*|\"[^\"]*\"))?"
请确保您的正则表达式正确无误。