[ 
https://issues.apache.org/jira/browse/HIVE-521?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12721231#action_12721231
 ] 

Min Zhou commented on HIVE-521:
-------------------------------

@ HIVE-521-all-v7.patch 

# {code:java}
boolean conditionTypeIsOk = (arguments[0].getCategory() == 
ObjectInspector.Category.PRIMITIVE);
if (conditionTypeIsOk) {
  PrimitiveObjectInspector poi = ((PrimitiveObjectInspector)arguments[0]);
  conditionTypeIsOk = (poi.getPrimitiveCategory() == 
PrimitiveObjectInspector.PrimitiveCategory.BOOLEAN
                       || poi.getPrimitiveCategory() == 
PrimitiveObjectInspector.PrimitiveCategory.VOID);
}
if (!conditionTypeIsOk) {
  throw new UDFArgumentTypeException(0,
      "The first argument of function IF should be \"" + 
Constants.BOOLEAN_TYPE_NAME
      + "\", but \"" + arguments[0].getTypeName() + "\" is found");
}
{code}
# {code:java}
    String typeName = arguments[0].getTypeName();
    if (!typeName.equals(Constants.BOOLEAN_TYPE_NAME)
            || !typeName.equals(Constants.VOID_TYPE_NAME)) {
      throw new UDFArgumentTypeException(0,
          "The first expression of function IF is expected to \"" + 
Constants.BOOLEAN_TYPE_NAME
          + "\", but \"" + arguments[0].getTypeName() + "\" is found");
    }
{code}

I though the 2nd approach is more concise, do you think so?

> Move size, if, isnull, isnotnull to GenericUDF
> ----------------------------------------------
>
>                 Key: HIVE-521
>                 URL: https://issues.apache.org/jira/browse/HIVE-521
>             Project: Hadoop Hive
>          Issue Type: Improvement
>    Affects Versions: 0.4.0
>            Reporter: Zheng Shao
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-521-all-v1.patch, HIVE-521-all-v2.patch, 
> HIVE-521-all-v3.patch, HIVE-521-all-v4.patch, HIVE-521-all-v5.patch, 
> HIVE-521-all-v6.patch, HIVE-521-all-v7.patch, HIVE-521-IF-2.patch, 
> HIVE-521-IF-3.patch, HIVE-521-IF-4.patch, HIVE-521-IF-5.patch, 
> HIVE-521-IF.patch
>
>
> See HIVE-511 for an example of the move.
> size, if, isnull, isnotnull are all implemented with UDF but they are 
> actually working on variable types of objects. We should move them to 
> GenericUDF for better type handling.
> This also helps to clean up the hack in doing type matching/type conversion 
> in UDF.

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

Reply via email to