Hive报错 NoViableAltException求助

在Hive中执行select split(value,':')[1] from ( select value from (select concat('num:',5,',fee:',3) as con_str)t1 lateral view explode (split(con_str,','))t1 as value );时报错如下:

NoViableAltException(-1@[207:51: ( KW_AS )?])
        at org.antlr.runtime.DFA.noViableAlt(DFA.java:158)
        at org.antlr.runtime.DFA.predict(DFA.java:144)
        at org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.subQuerySource(HiveParser_FromClauseParser.java:5246)
        at org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.fromSource(HiveParser_FromClauseParser.java:3684)
        at org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.joinSource(HiveParser_FromClauseParser.java:1836)
        at org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.fromClause(HiveParser_FromClauseParser.java:1488)
        at org.apache.hadoop.hive.ql.parse.HiveParser.fromClause(HiveParser.java:44977)
        at org.apache.hadoop.hive.ql.parse.HiveParser.singleSelectStatement(HiveParser.java:42035)
        at org.apache.hadoop.hive.ql.parse.HiveParser.selectStatement(HiveParser.java:41720)
        at org.apache.hadoop.hive.ql.parse.HiveParser.regularBody(HiveParser.java:41657)
        at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpressionBody(HiveParser.java:40710)
        at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpression(HiveParser.java:40586)
        at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1529)
        at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1065)
        at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:201)
        at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
        at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:522)
        at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1356)
        at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:1343)
        at org.apache.hive.service.cli.operation.SQLOperation.prepare(SQLOperation.java:185)
        at org.apache.hive.service.cli.operation.SQLOperation.runInternal(SQLOperation.java:271)
        at org.apache.hive.service.cli.operation.Operation.run(Operation.java:337)
        at org.apache.hive.service.cli.session.HiveSessionImpl.executeStatementInternal(HiveSessionImpl.java:439)
        at org.apache.hive.service.cli.session.HiveSessionImpl.executeStatementAsync(HiveSessionImpl.java:416)
        at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hive.service.cli.session.HiveSessionProxy.invoke(HiveSessionProxy.java:78)
        at org.apache.hive.service.cli.session.HiveSessionProxy.access$000(HiveSessionProxy.java:36)
        at org.apache.hive.service.cli.session.HiveSessionProxy$1.run(HiveSessionProxy.java:63)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1917)
        at org.apache.hive.service.cli.session.HiveSessionProxy.invoke(HiveSessionProxy.java:59)
        at com.sun.proxy.$Proxy19.executeStatementAsync(Unknown Source)
        at org.apache.hive.service.cli.CLIService.executeStatementAsync(CLIService.java:282)
        at org.apache.hive.service.cli.thrift.ThriftCLIService.ExecuteStatement(ThriftCLIService.java:501)
        at org.apache.hive.service.cli.thrift.TCLIService$Processor$ExecuteStatement.getResult(TCLIService.java:1313)
        at org.apache.hive.service.cli.thrift.TCLIService$Processor$ExecuteStatement.getResult(TCLIService.java:1298)
        at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
        at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
        at org.apache.hive.service.auth.TSetIpAddressProcessor.process(TSetIpAddressProcessor.java:56)
        at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:286)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
FAILED: ParseException line 1:153 cannot recognize input near '' '' '' in subquery source
Error: Error while compiling statement: FAILED: ParseException line 1:153 cannot recognize input near '' '' '' in subquery source (state=42000,code=40000)

经验证:
1.select value from (select concat('num:',5,',fee:',3) as con_str)t1 lateral view explode (split(con_str,','))t1 as value的查询结果如下:
±-------±-+
| value |
±-------±-+
| num:5 |
| fee:3 |
±-------±-+
2.如把上述sql转变为一张中间表create table temp as select value from (select concat('num:',5,',fee:',3) as con_str)t1 lateral view explode (split(con_str,','))t1 as value再结合select split(value,':')[1] from temp则不会报错,结果如下:
±-----±-+
| _c0 |
±-----±-+
| 5 |
| 3 |
±-----±-+
操作环境如下:
hive 1.1.0
hadoop 2.6.0
这到底是什么原因呢?求助。

你可能感兴趣的:(大数据,hive,报错信息)