wangyum opened a new pull request, #39691:
URL: https://github.com/apache/spark/pull/39691

   ### What changes were proposed in this pull request?
   
   The `QUALIFY` clause is used to filter the results of [window 
functions](https://spark.apache.org/docs/latest/sql-ref-syntax-qry-select-window.html).
 For example:
   ```sql
   -- QUALIFY with window functions in the SELECT list.
   SELECT
     city,
     car_model,
     RANK() OVER (PARTITION BY car_model ORDER BY quantity) AS rank
   FROM dealer
   QUALIFY rank = 1;
   
   -- QUALIFY with window functions in the QUALIFY clause.
   SELECT city, car_model
   FROM dealer
   QUALIFY RANK() OVER (PARTITION BY car_model ORDER BY quantity) = 1;
   +-----------+---------------+
   |   city    |   car_model   |
   +-----------+---------------+
   | San Jose  | Honda Accord  |
   | Dublin    | Honda CRV     |
   | San Jose  | Honda Civic   |
   +-----------+---------------+
   ```
   
   ### Why are the changes needed?
   
   To easily migrate SQL queries to Spark SQL.
   
   
https://docs.databricks.com/sql/language-manual/sql-ref-syntax-qry-select-qualify.html
   https://docs.snowflake.com/en/sql-reference/constructs/qualify.html
   
https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#qualify_clause
   https://duckdb.org/docs/sql/query_syntax/qualify.html
   
https://docs.teradata.com/reader/2_MC9vCtAJRlKle2Rpb0mA/19NnI91neorAi7LX6SJXBw
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Unit test.


-- 
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