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

UNION ALL on Aggregates with GROUP BY returns null when column aliases don't match

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Pending Closed
    • 0.9.0
    • 1.0.0
    • None

    Description

      The following query returns null :

      select x
      from
      (SELECT Sum(ss_ext_sales_price) x
      FROM  store_sales
      UNION ALL
      SELECT Sum(cs_ext_sales_price) y
      FROM catalog_sales) tmp
      GROUP BY x;
      
      Results from Drill:
      +------------+
      |     x      |
      +------------+
      | null       |
      +------------+
      1 row selected (3.458 seconds)
      
      Results from Postgres:
             x       
      ---------------
       3658019159.35
       5265207074.51
      (2 rows)
      

      Removing the GROUP BY returns correct results:

      select x
      from
      (SELECT Sum(ss_ext_sales_price) x
      FROM  store_sales
      UNION ALL
      SELECT Sum(cs_ext_sales_price) y
      FROM catalog_sales) tmp
      
      Results from Drill:
      +------------+
      |     x      |
      +------------+
      | 5265207074.51 |
      | 3658019159.35 |
      +------------+
      2 rows selected (3.46 seconds)
      

      Attachments

        Issue Links

          Activity

            People

              seanhychu Sean Hsuan-Yi Chu
              agirish Abhishek Girish
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: