Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-12223

Filter on Grouping__ID does not work properly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3.0, 2.0.0
    • 1.3.0, 2.0.0
    • Logical Optimizer
    • None

    Description

      Consider the following query:

      SELECT key, value, GROUPING__ID, count(*)
      FROM T1
      GROUP BY key, value
      GROUPING SETS ((), (key))
      HAVING GROUPING__ID = 1
      

      This query will not return results.

      The reason is that a "constant" placeholder is introduced by SemanticAnalyzer for the GROUPING__ID column. At execution time, this placeholder is replaced by the actual value of the GROUPING__ID. As the column is a constant, the Hive optimizer (combination of PPD and constant folding) will evaluate statically whether the condition is met or not, leading to incorrect results.

      We should be able to recognize the placeholder and avoid PPD pushing the filter predicate to the GroupBy operator.

      Attachments

        1. HIVE-12223.01.patch
          4 kB
          jcamachorodriguez
        2. HIVE-12223.patch
          7 kB
          jcamachorodriguez

        Activity

          People

            jcamacho Jesús Camacho Rodríguez
            jcamacho Jesús Camacho Rodríguez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: