Skip to main content

Synapse

New

Support QUALIFY in Spark SQL -- Necessary Quality of Life Feature

Vote (4) Share
Jonathan Boarman's profile image

Jonathan Boarman on 23 May 2024 22:22:51

Virtually all the key players in this space support this quality-of-life feature, including Databricks, Snowflake, BigQuery, DuckDB, and quite a few others.


The QUALIFY feature is a necessary feature to support any migration of existing SQL scripts. Significant re-architecture of existing SQL scripts would be necessary to migrate those projects into Fabric.


-- QUALIFY results to limit only to rank() == 1
SELECT
  city,
  car_model,
  RANK() OVER (PARTITION BY car_model ORDER BY quantity) AS rank
 FROM dealer
 QUALIFY rank = 1;


References:

https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#qualify_clause

https://docs.snowflake.com/en/sql-reference/constructs/qualify

https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-select-qualify.html

https://duckdb.org/docs/sql/query_syntax/qualify

Comments (1)
Jonathan Boarman's profile image Profile Picture

Jonathan Boarman on 11 Jun 2024 19:47:41

RE: Support QUALIFY in Spark SQL -- Necessary Quality of Life Feature

Apache Spark has an open issue on this that looks to be stuck and in need of being promoted with additional reviewers to accept the PR: https://issues.apache.org/jira/browse/SPARK-31561