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

Window sum over integer column returns incorrect results.

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      Window sum over integer column returns incorrect results.

      Drill 1.6.0, git commit ID : git.commit.id=64ab0a8e

      Note that Drill returns the same value for SUM(c2) in the below query.

      0: jdbc:drill:schema=dfs.tmp> select SUM(c2) OVER w as w_sum from ( SELECT * FROM t_alltype ORDER BY c1,c2 DESC NULLS LAST ) subquery WINDOW w AS (PARTITION BY c8 ORDER BY c2 DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
      +---------------+
      |     w_sum     |
      +---------------+
      | -16323034011  |
      | -16323034011  |
      | -16323034011  |
      ...
      | -16323034011  |
      | -16323034011  |
      | -16323034011  |
      | -16323034011  |
      | -16323034011  |
      +---------------+
      145 rows selected (0.683 seconds)
      

      Postgres 9.3

      postgres=#   select SUM(c2) OVER w as w_sum from ( SELECT * FROM t_alltype ORDER BY c1,c2 DESC NULLS LAST ) subquery WINDOW w AS (PARTITION BY c8 ORDER BY c2 DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
          w_sum
      -------------
       -8995559793
       -8995559793
       -8995559793
       -8995559793
       -8995559793
       -8995559793
       -8995559793
       ...
       -9169127412
       -9169127412
       -9169127412
       -9169127412
       -9169127412
       -9169127412
       -9169127412
       -9169127412
       ...
        1841653194
        1841653194
        1841653194
        1841653194
        1841653194
      (145 rows)
      

      Both in Drill and on Postgres there are 142 distinct rows and three nulls of the 145 total rows, in column c2.

      0: jdbc:drill:schema=dfs.tmp> select count(distinct c2) from t_alltype;
      +---------+
      | EXPR$0  |
      +---------+
      | 142     |
      +---------+
      1 row selected (0.682 seconds)
      0: jdbc:drill:schema=dfs.tmp> select c2 from t_alltype where c2 is null;
      +-------+
      |  c2   |
      +-------+
      | null  |
      | null  |
      | null  |
      +-------+
      3 rows selected (0.389 seconds)
      
      postgres=#  select count(distinct c2) from t_alltype;
       count
      -------
         142
      (1 row)
      
      postgres=# select c2 from t_alltype where c2 is null;
       c2
      ----
      
      
      
      (3 rows)
      

      Attachments

        1. t_alltype.csv
          17 kB
          Khurram Faraaz
        2. 0_0_0.parquet
          12 kB
          Khurram Faraaz

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            adeneche Abdel Hakim Deneche
            khfaraaz Khurram Faraaz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment