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

Let max/min handle complex types like struct

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.6.0
    • 0.6.0
    • None
    • None

    Description

      A lot of users are interested in doing "arg_min" and "arg_max". Basically, return the value of some other columns when one column's value is the max value.

      The following is an example usage when this is done:

      SELECT department, max(struct(salary, employee_name))
      FROM compensations
      GROUP BY department;
      
      SELECT department, max(struct(salary, employee_name)).col2 AS employee_name
      FROM compensations
      GROUP BY department;
      
      SELECT department, sen.col1 as salary, sen.col2 as employee_name
      FROM (
          SELECT department, max(struct(salary, employee_name)) AS sen
          FROM compensations
          GROUP BY department
      ) tmp
      
      

      Attachments

        1. HIVE-1128.1.sh
          0.3 kB
          Zheng Shao
        2. HIVE-1128.2.patch
          38 kB
          Zheng Shao

        Issue Links

          Activity

            People

              zshao Zheng Shao
              zshao Zheng Shao
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: