Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-18818

Window...orderBy() should accept an 'ascending' parameter just like DataFrame.orderBy()

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: PySpark, SQL
    • Labels:
      None

      Description

      It seems inconsistent that Window...orderBy() does not accept an ascending parameter, when DataFrame.orderBy() does.

      It's also slightly inconvenient since to specify a descending sort order you have to build a column object, whereas with the ascending parameter you don't.

      For example:

      from pyspark.sql.functions import row_number
      
      df.select(
          row_number()
          .over(
              Window
              .partitionBy(...)
              .orderBy('timestamp', ascending=False)))
      

      vs.

      from pyspark.sql.functions import row_number, col
      
      df.select(
          row_number()
          .over(
              Window
              .partitionBy(...)
              .orderBy(col('timestamp').desc())))
      

      It would be better if Window...orderBy() supported an ascending parameter just like DataFrame.orderBy().

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              nchammas Nicholas Chammas
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: