为什么使用 rank() 窗口函数会破坏解析器?

Why does using rank() windowing function break the parser?

spark sql 的窗口函数在线文档包括以下示例:

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。但是不行

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
                        ^

谁能看出它们在结构上的不同之处?我从 2015 年 11 月 18 日开始使用 spark 1.6.0-SNAPSHOT。

我检查了源代码,看来 rank() 需要 hive 支持。我正在用

重建 spark
 -Phive -Phive-thriftserver

我确实确认:使用 HiveContext 时查询有效。