Hi Saurabh,

Ahish is right.  You udf must inherit UDF or GenericUDF.  If you build that
udf class into a seperate jar,  "add jar " command should be run at first.

hive> add jar jar_path;
hive> create temporary function udf_name as 'UdfClass';

Hope helpful.


Min

On Wed, Jul 15, 2009 at 2:44 AM, Ashish Thusoo <[email protected]> wrote:

>  Not sure if you got an answer for this.
>
> You can look at the following test case in the source tree to guide you on
> how to build a udf. Will put this on the wiki.
>
> create_genericudf.q
> udf_testlength.q
>
> The udf has to implement either the UDF interface or the GenericUDF
> interface. The later handles cases for UDFs that can take complex objects as
> arguments or have variable length arguments or return complex objects. The
> UDF interface is easier to program to, but is more limited than the
> GenericUDF interface.
>
> There are some nuances that you need to be aware of about the function
> resolution logic incase the UDF has polymorphism in the evaluate functions.
> I can go into more details if that is the case for you.
>
> Ashish
>
>
>  ------------------------------
> *From:* Saurabh Nanda [mailto:[email protected]]
> *Sent:* Tuesday, July 14, 2009 1:09 AM
> *To:* [email protected]
> *Subject:* Creating a UDF (was Hive SerDe?)
>
> I'm trying to register a UDF to parse my log file format. Where can I find
> documentation for creating and registering a UDF?
>
> My attempts failed with this error:
>
> hive> create temporary function process_line as 'LogProcessor';
> FAILED: Unknown exception : Registering UDF Class class LogProcessor which
> does not extends class org.apache.hadoop.hive.ql.exec.UDF
>
> Specific questions:
>
> 1. Do I need to define the a particular function in the class? For example,
> run()
> 2. What arguments should that function accept?
> 3. What should be the return type of that function?
> 4. What if the function needs to return multiple values? Each value mapping
> to a column in the table?
>
> Saurabh.
> --
> http://nandz.blogspot.com
> http://foodieforlife.blogspot.com
>



-- 
My research interests are distributed systems, parallel computing and
bytecode based virtual machine.

My profile:
http://www.linkedin.com/in/coderplay
My blog:
http://coderplay.javaeye.com

Reply via email to