为什么使用 rank() 窗口函数会破坏解析器? [英] Why does using rank() windowing function break the parser?
本文介绍了为什么使用 rank() 窗口函数会破坏解析器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
spark sql 的窗口函数在线文档包括以下示例:
The windowing functions online docs for spark sql include the following example:
https://databricks.com/blog/2015/07/15/introducing-window-functions-in-spark-sql.html
SELECT
product,
category,
revenue
FROM (
SELECT
product,
category,
revenue,
dense_rank() OVER (PARTITION BY category ORDER BY revenue DESC) as rank
FROM productRevenue) tmp
WHERE
rank <= 2
我已经创建了一个看起来类似结构的 sql.但它不起作用
I have created what would seem to be a similar structure sql. But it does not work
select id,r from (
select id, name,
rank() over (partition by name order by name) as r
from tt) v
where v.r >= 7 and v.r <= 12
这里是错误:
Exception in thread "main" java.lang.RuntimeException: [3.25]
failure: ``)'' expected but `(' found
rank() over (partition by fp order by fp) as myrank
^
谁能看出它们在结构上的不同之处?我从 15 年 11 月 18 日开始使用 spark 1.6.0-SNAPSHOT.
Anyone can see where they differ structurally? I am on spark 1.6.0-SNAPSHOT from 11/18/15.
推荐答案
我检查了源代码,似乎 rank() 需要 hive 支持.我正在用
I checked the source code and it appears the rank() requires hive support. I am rebuilding spark with
-Phive -Phive-thriftserver
我确实确认:当使用 HiveContext
时,查询有效.
I did confirm: when using a HiveContext
the query works.
这篇关于为什么使用 rank() 窗口函数会破坏解析器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文