hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From java8964 java8964 <>
Subject How can I get the constant value from the ObjectInspector in the UDF
Date Tue, 25 Sep 2012 19:17:14 GMT

Hi, I am using Cloudera release cdh3u3, which has the hive 0.71 version.
I am trying to write a hive UDF function as to calculate the moving sum. Right now, I am having
trouble to get the constrant value passed in in the initialization stage.
For example, let's assume the function is like the following format:
msum(salary, 10) --------- salary is a int type column
which means the end user wants to calculate the last 10 rows of salary.
I kind of know how to implement this UDF. But I have one problem right now.
1) This is not a UDAF, as each row will return one data back as the moving sum.2) I create
an UDF class extends from the GenericUDF.3) I can get the column type from the ObjectInspector[]
passed to me in the initialize() method to verify that 'salary' and 10 both needs to be numeric
type (later one needs to be integer)4) But I also want to get the real value of 10, in this
case, in the initialize() stage, so I can create the corresponding data structure based on
the value end user specified here.5) I looks around the javadoc of ObjectInspector class.
I know at run time the real class of the 2nd parameter is WritableIntObjectInspector. I can
get the type, but how I can get the real value of it?6) This is kind of ConstantsObjectInspector,
should be able to give the value to me, as it already knows the type is int. What how?7) I
don't want to try to get the value at the evaluate stage. Can I get this value at the initialize
View raw message