0
votes

I'm going through the installation of Hadoop/Pig/Thrift/Hive. I've got it all working so far, however I am running into an issue when creating a table which contains a Serde. This is actually a copy/paste from the official documentation from Hive.

Can anyone tell me what is wrong with it?

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;

The error which I encounter when running this through is:

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
1

1 Answers

1
votes

Looks like you are missing spaces in your regex :

"input.regex" = "([^ ]*) ([^ ]*) ([^ ]*) (-|\\[[^\\]]*\\])
([^ \"]*|\"[^\"]*\") (-|[0-9]*) (-|[0-9]*)(?: ([^ \"]*|\"[^\"]*\")
([^ \"]*|\"[^\"]*\"))?"

Please make sure your regex is correct.