如何在配置单元0.13中使用带空格的别名

rseugnpd  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(337)

我在HDP2.1调音台,Hive0.13。我想在查询中使用带空格的别名,但出现错误,是否可以在别名中使用空格(它在没有空间别名的情况下工作正常。尝试单引号,没有引号仍然失败。


* hive> select ot_vdot "alias test" from test4 where ot_vdot<>'null';

NoViableAltException(301@[146:1: selectExpression : ( expression | tableAllColumns );])
    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_SelectClauseParser.selectExpression(HiveParser_SelectClauseParser.java:4142)
    at org.apache.hadoop.hive.ql.parse.HiveParser_SelectClauseParser.selectItem(HiveParser_SelectClauseParser.java:3038)
    at org.apache.hadoop.hive.ql.parse.HiveParser_SelectClauseParser.selectList(HiveParser_SelectClauseParser.java:1307)
    at org.apache.hadoop.hive.ql.parse.HiveParser_SelectClauseParser.selectClause(HiveParser_SelectClauseParser.java:1070)
    at org.apache.hadoop.hive.ql.parse.HiveParser.selectClause(HiveParser.java:40193)
    at org.apache.hadoop.hive.ql.parse.HiveParser.singleSelectStatement(HiveParser.java:38048)
    at org.apache.hadoop.hive.ql.parse.HiveParser.selectStatement(HiveParser.java:37754)
    at org.apache.hadoop.hive.ql.parse.HiveParser.regularBody(HiveParser.java:37691)
    at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpressionBody(HiveParser.java:36898)
    at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpression(HiveParser.java:36774)
    at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1338)
    at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1036)
    at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:199)
    at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
    at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:408)
    at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:322)
    at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:976)
    at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1041)
    at org.apache.hadoop.hive.ql.Driver.run(Driver.java:912)
    at org.apache.hadoop.hive.ql.Driver.run(Driver.java:902)
    at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:268)
    at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:220)
    at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:423)
    at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:793)
    at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:686)
    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:625)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
FAILED: ParseException line 1:15 cannot recognize input near 'ot_vdot' '"alias test"'  'from' in select expression
hive>

* 
wn9m85ua

wn9m85ua1#

backticks是hive用奇怪的字符或保留的单词来命名事物的方法。例如:

select `my field with spaces`, `select`, `where` from `_my_table`

相关问题