Hive
  1. Hive
  2. HIVE-1790

Patch to support HAVING clause in Hive

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.7.0
    • Component/s: Query Processor
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      Currently Hive users have to do nested queries in order to apply filter on group by expressions.
      This patch allows users to directly apply filter on group by expressions by using HAVING clause.
      This patch also helps us integrate Hive with other data analysis tools which rely on HAVING expression.

      1. HIVE-1790-1.patch
        27 kB
        Vaibhav Aggarwal
      2. HIVE-1790.patch
        12 kB
        Vaibhav Aggarwal
      3. HIVE-1790.4.patch.txt
        36 kB
        Vaibhav Aggarwal
      4. HIVE-1790.3.patch.txt
        25 kB
        Carl Steinbach
      5. HIVE-1790.2.patch.txt
        25 kB
        Carl Steinbach

        Issue Links

          Activity

          Vaibhav Aggarwal created issue -
          Vaibhav Aggarwal made changes -
          Field Original Value New Value
          Attachment HIVE-1790.patch [ 12459511 ]
          John Sichi made changes -
          Link This issue duplicates HIVE-1337 [ HIVE-1337 ]
          Hide
          Carl Steinbach added a comment -

          @Vaibhav: is this ready for review, or are you still working on it?

          Show
          Carl Steinbach added a comment - @Vaibhav: is this ready for review, or are you still working on it?
          Carl Steinbach made changes -
          Component/s Query Processor [ 12312586 ]
          Issue Type Improvement [ 4 ] New Feature [ 2 ]
          Fix Version/s 0.7.0 [ 12315150 ]
          Hide
          Vaibhav Aggarwal added a comment -

          Hi

          I think the patch is ready for review.
          This is my first attempt though.

          Thanks
          Vaibhav

          Show
          Vaibhav Aggarwal added a comment - Hi I think the patch is ready for review. This is my first attempt though. Thanks Vaibhav
          Hide
          Carl Steinbach added a comment -

          @Vaibhav: can you please add some test cases to the patch and verify that they pass?

          Directions explaining how to add tests are on the Hive wiki here: http://wiki.apache.org/hadoop/Hive/DeveloperGuide#Adding_new_unit_tests

          Show
          Carl Steinbach added a comment - @Vaibhav: can you please add some test cases to the patch and verify that they pass? Directions explaining how to add tests are on the Hive wiki here: http://wiki.apache.org/hadoop/Hive/DeveloperGuide#Adding_new_unit_tests
          Hide
          Vaibhav Aggarwal added a comment -

          Hey Carl

          Do you know how to access the schema and data in the staging tables?
          I am not able to find the table "src" anywhere in the hive codebase.

          Show
          Vaibhav Aggarwal added a comment - Hey Carl Do you know how to access the schema and data in the staging tables? I am not able to find the table "src" anywhere in the hive codebase.
          Hide
          Carl Steinbach added a comment -

          The test tables are created by the QTestUtil.createSources() method located in ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java

          The data used to initialize these tables is stored in the data/files directory.

          Show
          Carl Steinbach added a comment - The test tables are created by the QTestUtil.createSources() method located in ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java The data used to initialize these tables is stored in the data/files directory.
          Vaibhav Aggarwal made changes -
          Attachment HIVE-1790-1.patch [ 12459672 ]
          Hide
          Vaibhav Aggarwal added a comment -

          I have added test cases and have uploaded a new patch.

          Show
          Vaibhav Aggarwal added a comment - I have added test cases and have uploaded a new patch.
          Carl Steinbach made changes -
          Link This issue is required by HIVE-1386 [ HIVE-1386 ]
          Hide
          Carl Steinbach added a comment -

          Attaching a new version of the patch that has been rebased to trunk. I could not
          get the original to apply cleanly with patch -p0.

          Show
          Carl Steinbach added a comment - Attaching a new version of the patch that has been rebased to trunk. I could not get the original to apply cleanly with patch -p0.
          Carl Steinbach made changes -
          Attachment HIVE-1790.2.patch.txt [ 12465952 ]
          Hide
          Carl Steinbach added a comment -

          Accidentally picked up one of my own changes with the last patch. Attaching a new copy that includes
          only Vaibhav's work.

          Show
          Carl Steinbach added a comment - Accidentally picked up one of my own changes with the last patch. Attaching a new copy that includes only Vaibhav's work.
          Carl Steinbach made changes -
          Attachment HIVE-1790.3.patch.txt [ 12465955 ]
          Hide
          Carl Steinbach added a comment -

          Posted review comments here: https://reviews.apache.org/r/162/

          Show
          Carl Steinbach added a comment - Posted review comments here: https://reviews.apache.org/r/162/
          Vaibhav Aggarwal made changes -
          Attachment HIVE-1790.4.patch.txt [ 12466677 ]
          Hide
          Vaibhav Aggarwal added a comment -

          Hi

          I have addressed all the user comments and have attached a new patch.

          Please review the patch.

          Show
          Vaibhav Aggarwal added a comment - Hi I have addressed all the user comments and have attached a new patch. Please review the patch.
          Hide
          Vaibhav Aggarwal added a comment -

          Please note that I have not created a common method for genFilterPlan and genHavingPlan.
          The genHavingPlan needs to populate the input row resolver with additional information related to column aliases.
          It is not happening in genFilterPlan.
          I don't think that there is lot of common code between the two methods. In this case I would prefer separate methods over if statements in code. It keeps the control flow much cleaner.

          Show
          Vaibhav Aggarwal added a comment - Please note that I have not created a common method for genFilterPlan and genHavingPlan. The genHavingPlan needs to populate the input row resolver with additional information related to column aliases. It is not happening in genFilterPlan. I don't think that there is lot of common code between the two methods. In this case I would prefer separate methods over if statements in code. It keeps the control flow much cleaner.
          Hide
          Carl Steinbach added a comment -

          @Vaibhav: Please change the status of the ticket to "patch available" when
          'you're ready to have something reviewed.

          Show
          Carl Steinbach added a comment - @Vaibhav: Please change the status of the ticket to "patch available" when 'you're ready to have something reviewed.
          Carl Steinbach made changes -
          Status Open [ 1 ] Patch Available [ 10002 ]
          Hide
          Carl Steinbach added a comment -

          Committed. Thanks Vaibhav!

          Show
          Carl Steinbach added a comment - Committed. Thanks Vaibhav!
          Carl Steinbach made changes -
          Status Patch Available [ 10002 ] Resolved [ 5 ]
          Hadoop Flags [Reviewed]
          Resolution Fixed [ 1 ]
          Carl Steinbach made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Vaibhav Aggarwal
              Reporter:
              Vaibhav Aggarwal
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development