Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-30374 Feature Parity between PostgreSQL and Spark (ANSI/SQL)
  3. SPARK-30395

When one or more DISTINCT aggregate expressions operate on the same field, the DISTINCT aggregate expression allows the use of the FILTER clause

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 3.0.0
    • None
    • SQL
    • None

    Description

      This ticket is related to https://issues.apache.org/jira/browse/SPARK-27986

      This ticket will support:

      When one or more DISTINCT aggregate expressions operate on the same field, the DISTINCT aggregate expression allows the use of the FILTER clause

      such as:

       

      select sum(distinct id) filter (where sex = 'man') from student;
      select class_id, sum(distinct id) filter (where sex = 'man') from student group by class_id;
      select count(id) filter (where class_id = 1), sum(distinct id) filter (where sex = 'man') from student;
      select class_id, count(id) filter (where class_id = 1), sum(distinct id) filter (where sex = 'man') from student group by class_id;
      select sum(distinct id), sum(distinct id) filter (where sex = 'man') from student;
      select class_id, sum(distinct id), sum(distinct id) filter (where sex = 'man') from student group by class_id;
      select class_id, count(id), count(id) filter (where class_id = 1), sum(distinct id), sum(distinct id) filter (where sex = 'man') from student group by class_id;
      

       

       but not support:

       

      select class_id, count(distinct sex), sum(distinct id) filter (where sex = 'man') from student group by class_id;
      select class_id, count(distinct sex) filter (where class_id = 1), sum(distinct id) filter (where sex = 'man') from student group by class_id;

      https://issues.apache.org/jira/browse/SPARK-30396 used for later.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              beliefer jiaan.geng
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: