How to convert SQL query to Pyspark Sql query

Viewed 58

How to convert below SQL to pyspark SQL

WITH groups AS (
   SELECT  RANK() OVER (ORDER BY date_completed) AS row_number,
        date_completed,
        DATEADD (day, -RANK() OVER (ORDER BY date_completed),
        date_completed) AS date_group
FROM lesson_completed)

 SELECT  COUNT(*) AS days_streak,
    MIN (date_completed) AS min_date,
    MAX (date_completed) AS max_date
 FROM groups
 GROUP BY date_group

the above SQL I need in pyspark3.1x

0 Answers
Related