hive中分号字符引起的异常

在使用正则表达式时候解析数据时候,由输入带有分号的字符串引起的异常错误

select regexp_extract(reflect("java.net.URLDecoder", "decode", event),';price=(\\d+-\\d+)(&|;)',1) from page_url;

select ';price=(\\d+-\\d+)(&|;)';

hive日志中报出字符异常

NoViableAltException(-1@[])
	at org.apache.hadoop.hive.ql.parse.HiveParser_SelectClauseParser.selectClause(HiveParser_SelectClauseParser.java:1089)
	at org.apache.hadoop.hive.ql.parse.HiveParser.selectClause(HiveParser.java:45886)
	at org.apache.hadoop.hive.ql.parse.HiveParser.selectStatement(HiveParser.java:41503)
	at org.apache.hadoop.hive.ql.parse.HiveParser.regularBody(HiveParser.java:41410)
	at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpressionBody(HiveParser.java:40421)
	at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpression(HiveParser.java:40291)
	at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1598)
	at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1117)
	at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:202)
	at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
	at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:426)
	at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:314)
	at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1164)
	at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1212)
	at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1101)
	at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1091)
	at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:216)
	at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:168)
	at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:379)
	at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:739)
	at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:684)
	at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:624)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
FAILED: ParseException line 1:8 cannot recognize input near '' '' '' in select clause

将分号; 进行ASCII码转换输入,分号对应ascii为59

hive> 
    > 
    > select concat('\073price=(\\d+-\\d+)(&|\073)' ); 
OK
;price=(\d+-\d+)(&|;)
Time taken: 0.064 seconds, Fetched: 1 row(s)


ASCII码对应参照表:http://tool.oschina.net/commons?type=4

你可能感兴趣的:(hive)