Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-3358

CUME_DIST window function provides wrong result when only ORDER BY clause is specified

    XMLWordPrintableJSON

Details

    Description

      Drill:

      > SELECT CUME_DIST() OVER (ORDER BY ss.ss_store_sk) FROM store_sales ss ORDER BY 1 LIMIT 20;
      +---------------------+
      |       EXPR$0        |
      +---------------------+
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      | 0.9923989432198661  |
      +---------------------+
      20 rows selected (17.317 seconds)
      

      Postgres

      # SELECT CUME_DIST() OVER (ORDER BY ss.ss_store_sk) FROM store_sales ss ORDER BY 1 LIMIT 20;
           cume_dist    
      
      -------------------
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
       0.158622193275665
      (20 rows)
      

      Attachments

        Issue Links

          Activity

            People

              adeneche Abdel Hakim Deneche
              agirish Abhishek Girish
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: