在蜂巢中不使用窗口函数的情况下实现Dense_rank函数

时间:2018-07-24 11:08:54

标签: hive dense-rank windowing

我正在尝试不使用窗口函数(dense_rank)来实现密集等级函数。

在尝试使用以下查询:

select deptID, salary, 
(select count(distinct Salary) 
 from Employee e 
 where e.deptID = Employee.deptID and e.salary >= Employee.Salary) as dense_rank 
from Employee order by deptID, Salary Desc;

在配置单元中执行此查询时出现以下错误:

  

NoViableAltException(244 @ [435:1:PriorityEqualExpression:(((LPAREN PriorityBitwiseOrExpression COMMA)=> PriorityEqualExpressionMutiple | priorityEqualExpressionSingle);])       在org.antlr.runtime.DFA.noViableAlt(DFA.java:158)       在org.antlr.runtime.DFA.predict(DFA.java:116)       在org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceEqualExpression(HiveParser_IdentifiersParser.java:8221)       在org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceNotExpression(HiveParser_IdentifiersParser.java:10008)       在org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceAndExpression(HiveParser_IdentifiersParser.java:10127)       在org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceOrExpression(HiveParser_IdentifiersParser.java:10286)       在org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.expression(HiveParser_IdentifiersParser.java:6218)       在org.apache.hadoop.hive.ql.parse.HiveParser.expression(HiveParser.java:51844)       在org.apache.hadoop.hive.ql.parse.HiveParser_SelectClauseParser.selectItem(HiveParser_SelectClauseParser.java:2951)       在org.apache.hadoop.hive.ql.parse.HiveParser_SelectClauseParser.selectList(HiveParser_SelectClauseParser.java:1467)       在org.apache.hadoop.hive.ql.parse.HiveParser_SelectClauseParser.selectClause(HiveParser_SelectClauseParser.java:1194)       在org.apache.hadoop.hive.ql.parse.HiveParser.selectClause(HiveParser.java:51847)       在org.apache.hadoop.hive.ql.parse.HiveParser.selectStatement(HiveParser.java:45661)       在org.apache.hadoop.hive.ql.parse.HiveParser.regularBody(HiveParser.java:45568)       在org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpressionBody(HiveParser.java:44584)       在org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpression(HiveParser.java:44454)       在org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1696)       在org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1178)       在org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:204)       在org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)       在org.apache.hadoop.hive.ql.Driver.compile(Driver.java:404)       在org.apache.hadoop.hive.ql.Driver.compile(Driver.java:329)       在org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1158)       在org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1253)       在org.apache.hadoop.hive.ql.Driver.run(Driver.java:1084)       在org.apache.hadoop.hive.ql.Driver.run(Driver.java:1072)       在org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:232)       在org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:183)       在org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:399)       在org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:776)       在org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:714)       在org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:641)       在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处       在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)       在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)       在java.lang.reflect.Method.invoke(Method.java:498)       在org.apache.hadoop.util.RunJar.run(RunJar.java:221)       在org.apache.hadoop.util.RunJar.main(RunJar.java:136)   失败:ParseException行1:24无法识别表达式规范中'(''select''count'附近的输入

请让我如何克服此错误,而无需使用dense_rank()

,我们可以获得与密集等级相同的功能

0 个答案:

没有答案