You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Larry Ogrodnek <la...@bizo.com> on 2011/04/05 20:20:01 UTC

UDF constructor params?

For some UDFs I'm working on now it feels like it would be handy to be
able to pass in parameters during construction.  It's an integration
with an external reporting API...

e.g.

-- include last 30 days from april 4th
create temporary function orders_last_month as
'com.example.OrderSearch("20110404", 30)'

-- get orders for customer 11
select order_last_month(11), ...


Obviously I can perform the same logic passing everything into the UDF:

select orders_last_month("20110404", 30, 11), ...


but this doesn't feel as nice..

additionally, having the information available in the constructor
might give the UDF more information on how to perform caching, allow
it to do more complex initialization, etc.


Just wondering if this has ever been thought about, discussed, or
needed by anyone else....

thanks,
larry

Re: UDF constructor params?

Posted by Edward Capriolo <ed...@gmail.com>.
On Tue, Apr 5, 2011 at 2:20 PM, Larry Ogrodnek <la...@bizo.com> wrote:
> For some UDFs I'm working on now it feels like it would be handy to be
> able to pass in parameters during construction.  It's an integration
> with an external reporting API...
>
> e.g.
>
> -- include last 30 days from april 4th
> create temporary function orders_last_month as
> 'com.example.OrderSearch("20110404", 30)'
>
> -- get orders for customer 11
> select order_last_month(11), ...
>
>
> Obviously I can perform the same logic passing everything into the UDF:
>
> select orders_last_month("20110404", 30, 11), ...
>
>
> but this doesn't feel as nice..
>
> additionally, having the information available in the constructor
> might give the UDF more information on how to perform caching, allow
> it to do more complex initialization, etc.
>
>
> Just wondering if this has ever been thought about, discussed, or
> needed by anyone else....
>
> thanks,
> larry
>

You can put that information inside the configuation or file system
and access it from the UDF.

Re: UDF constructor params?

Posted by John Sichi <js...@fb.com>.
https://issues.apache.org/jira/browse/HIVE-1016
https://issues.apache.org/jira/browse/HIVE-1360

JVS

On Apr 5, 2011, at 11:20 AM, Larry Ogrodnek wrote:

> For some UDFs I'm working on now it feels like it would be handy to be
> able to pass in parameters during construction.  It's an integration
> with an external reporting API...
> 
> e.g.
> 
> -- include last 30 days from april 4th
> create temporary function orders_last_month as
> 'com.example.OrderSearch("20110404", 30)'
> 
> -- get orders for customer 11
> select order_last_month(11), ...
> 
> 
> Obviously I can perform the same logic passing everything into the UDF:
> 
> select orders_last_month("20110404", 30, 11), ...
> 
> 
> but this doesn't feel as nice..
> 
> additionally, having the information available in the constructor
> might give the UDF more information on how to perform caching, allow
> it to do more complex initialization, etc.
> 
> 
> Just wondering if this has ever been thought about, discussed, or
> needed by anyone else....
> 
> thanks,
> larry