org.apache.hadoop.hive.ql.udf.generic
Class GenericUDFRound
java.lang.Object
org.apache.hadoop.hive.ql.udf.generic.GenericUDF
org.apache.hadoop.hive.ql.udf.generic.GenericUDFRound
- All Implemented Interfaces:
- Closeable
public class GenericUDFRound
- extends GenericUDF
Note: rounding function permits rounding off integer digits in decimal numbers, which essentially
downgrades the scale to negative territory. However, Hive decimal only allow non-negative scales.
This can cause confusion, for example, when a decimal number 1234.567 of type decimal(7,3) is
rounded with -2 scale, which produces a decimal number, 1200. The type of the output is
decimal(5,0), which does not exactly represents what the number means. Thus, user should
be aware of this, and use negative rounding for decimal with caution. However, Hive is in line
with the behavior that MYSQL demonstrates.
At a certain point, we should probably support negative scale for decimal type.
GenericUDFRound.
GenericUDFRound
public GenericUDFRound()
initialize
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException
- Description copied from class:
GenericUDF
- Initialize this GenericUDF. This will be called once and only once per
GenericUDF instance.
- Specified by:
initialize
in class GenericUDF
- Parameters:
arguments
- The ObjectInspector for the arguments
- Returns:
- The ObjectInspector for the return value
- Throws:
UDFArgumentException
- Thrown when arguments have wrong types, wrong length, etc.
evaluate
public Object evaluate(GenericUDF.DeferredObject[] arguments)
throws HiveException
- Description copied from class:
GenericUDF
- Evaluate the GenericUDF with the arguments.
- Specified by:
evaluate
in class GenericUDF
- Parameters:
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.
- Returns:
- The
- Throws:
HiveException
getDisplayString
public String getDisplayString(String[] children)
- Description copied from class:
GenericUDF
- Get the String to be displayed in explain.
- Specified by:
getDisplayString
in class GenericUDF
Copyright © 2014 The Apache Software Foundation. All rights reserved.