zhengruifeng commented on pull request #34367:
URL: https://github.com/apache/spark/pull/34367#issuecomment-978884601


   @wangyum 
   
   this PR was updated to support `rank` and `dense_rank`
   
   ```
   scala> spark.conf.set("spark.sql.rankLimit.enabled", "true")
   
   scala> spark.sql("""SELECT a, b, rank() OVER (PARTITION BY a ORDER BY b) as 
rk FROM VALUES ('A1', 1), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, 
b);""").where("rk = 1").queryExecution.optimizedPlan
   res1: org.apache.spark.sql.catalyst.plans.logical.LogicalPlan =
   Filter (rk#0 = 1)
   +- Window [rank(b#4) windowspecdefinition(a#3, b#4 ASC NULLS FIRST, 
specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#0], 
[a#3], [b#4 ASC NULLS FIRST]
      +- RankLimit [a#3], [b#4 ASC NULLS FIRST], rank(b#4), 1
         +- LocalRelation [a#3, b#4]
   
   scala> spark.sql("""SELECT a, b, rank() OVER (PARTITION BY a ORDER BY b) as 
rk FROM VALUES ('A1', 1), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, 
b);""").where("rk = 1").show
   +---+---+---+                                                                
   
   |  a|  b| rk|
   +---+---+---+
   | A1|  1|  1|
   | A1|  1|  1|
   | A1|  1|  1|
   | A2|  3|  1|
   +---+---+---+
   
   ```
   
   
![image](https://user-images.githubusercontent.com/7322292/143392842-c046c52d-a31d-4af9-aed9-ef16714ebb45.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to