hadoop-hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zheng Shao (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HIVE-164) Support CASE statement using GenericUDF
Date Thu, 23 Apr 2009 21:15:30 GMT

     [ https://issues.apache.org/jira/browse/HIVE-164?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Zheng Shao updated HIVE-164:
----------------------------

    Attachment: HIVE-164.6.patch

Simplified the interface for GenericUDF. I guess it's easy to write a GenericUDF without too
much knowledge of Hive (the developer will still need to know about ObjectInspector).

{code}
@UDFType(deterministic=true)
public abstract class GenericUDF {
  
  /**
   * A Defered Object allows us to do lazy-evaluation
   * and short-circuiting.
   * GenericUDF use DeferedObject to pass arguments.
   */
  public static interface DeferredObject {
    public Object get() throws HiveException; 
  };
  
  /**
   * The constructor
   */
  public GenericUDF() {
  }

  /**
   * Initialize this GenericUDF. This will be called once and only once per
   * GenericUDF instance.
   * 
   * @param arguments     The ObjectInspector for the arguments
   * @throws UDFArgumentTypeException
   *                      Thrown when arguments have wrong types
   * @return              The ObjectInspector for the return value
   */
  public abstract ObjectInspector initialize(ObjectInspector[] arguments) 
      throws UDFArgumentTypeException;
  
  /**
   * Evaluate the GenericUDF with the arguments.
   * @param arguments  The arguments as DeferedObject, use DeferedObject.get() to
   *                   get the actual argument Object.  The Objects can be inspected
   *                   by the ObjectInspectors passed in the initialize call.
   * @return The 
   */
  public abstract Object evaluate(DeferredObject[] arguments) throws HiveException;
  
  /**
   * Get the String to be displayed in explain.
   */
  public abstract String getDisplayString(String[] children);
  
}
{code}


> Support CASE statement using GenericUDF
> ---------------------------------------
>
>                 Key: HIVE-164
>                 URL: https://issues.apache.org/jira/browse/HIVE-164
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>            Reporter: Zheng Shao
>            Assignee: Zheng Shao
>         Attachments: HIVE-164.4.patch, HIVE-164.5.patch, HIVE-164.6.patch
>
>
> See http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html for details.
> Syntax:
> {code}
> CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result ...] [<ELSE
result] END
> CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END

> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message