Why does using the window's ranking () function break the parser?

The online window document functions for the sql spark 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

I created what looks like a similar sql structure. But that 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

Here is the error:

Exception in thread "main" java.lang.RuntimeException: [3.25] 
      failure: ``)'' expected but `(' found

            rank() over (partition by fp order by fp) as myrank
                        ^

Can anyone see where they differ structurally? I'm on a spark 1.6.0-SNAPSHOT from 11/18/15.

+1
source share
1 answer

I checked the source code and it seems rank () requires hive support . I restore the spark with

 -Phive -Phive-thriftserver

I confirmed: when using HiveContext, the request is executed.

+3
source

Source: https://habr.com/ru/post/1629524/


All Articles