'replace qualify to use in Spark SQL

I want to convert this Teradata sql to Spark compatible SQL, hot to do it?

SELECT * FROM table_name qualify rank(col_name)=1;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source