You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@drill.apache.org by Muhammad Gelbana <m....@gmail.com> on 2017/01/23 09:18:21 UTC

UDF parameters

I need to create a UDF with the following properties:

   - Accepts variable amount of parameters (1, 2, 3...etc parameters)
   - Some or all the parameters may be null
   - All parameters are numerical
   - Some or all the parameters may be fed by literals or columns selected
   from a parquet file (*SELECT my_udf(COL1, COL2, 123) FROM
   dfs.`path_to_parquet_file`*)
   - Depending on the parameters, the UDF may return NULL.

When I use a Nullable holder such as *NullableVarChar*, I can't pass it a
literal value because the method signature expects an optional value (i.e.
a value from a column that *may* by null, not always having a value such as
a literal)

Remember that the UDF need to have a variable amount of parameters. If this
is not currently possible, I'll have to create multiple UDFs with multiple
amount of parameters and if I do that, I will desperately need a *single*
value holder type that accepts columns, literals, integers and doubles.

My questions are

   1. Is there a value holder that accepts literals & columns for integers
   & doubles ?
   2. Is there a value holder that accepts any kind of input ? Like
   *java.util.Object* in java ?


*---------------------*
*Muhammad Gelbana*
http://www.linkedin.com/in/mgelbana

Re: UDF parameters

Posted by Gautam Parai <gp...@mapr.com>.
Yes, the ObjectHolder can store any arbitrary object. You are responsible for casting it into the appropriate type when reading from the ObjectHolder.


But, I think it is listed as deprecated.


Gautam

________________________________
From: Muhammad Gelbana <m....@gmail.com>
Sent: Monday, January 23, 2017 1:18:21 AM
To: user@drill.apache.org
Subject: UDF parameters

I need to create a UDF with the following properties:

   - Accepts variable amount of parameters (1, 2, 3...etc parameters)
   - Some or all the parameters may be null
   - All parameters are numerical
   - Some or all the parameters may be fed by literals or columns selected
   from a parquet file (*SELECT my_udf(COL1, COL2, 123) FROM
   dfs.`path_to_parquet_file`*)
   - Depending on the parameters, the UDF may return NULL.

When I use a Nullable holder such as *NullableVarChar*, I can't pass it a
literal value because the method signature expects an optional value (i.e.
a value from a column that *may* by null, not always having a value such as
a literal)

Remember that the UDF need to have a variable amount of parameters. If this
is not currently possible, I'll have to create multiple UDFs with multiple
amount of parameters and if I do that, I will desperately need a *single*
value holder type that accepts columns, literals, integers and doubles.

My questions are

   1. Is there a value holder that accepts literals & columns for integers
   & doubles ?
   2. Is there a value holder that accepts any kind of input ? Like
   *java.util.Object* in java ?


*---------------------*
*Muhammad Gelbana*
http://www.linkedin.com/in/mgelbana

Re: UDF parameters

Posted by Kunal Khatua <kk...@mapr.com>.
Have you tried looking at the String manipulation function - CONCATE function as a reference to achieve your goal?


Kunal Khatua

________________________________
From: Muhammad Gelbana <m....@gmail.com>
Sent: Monday, January 23, 2017 1:18:21 AM
To: user@drill.apache.org
Subject: UDF parameters

I need to create a UDF with the following properties:

   - Accepts variable amount of parameters (1, 2, 3...etc parameters)
   - Some or all the parameters may be null
   - All parameters are numerical
   - Some or all the parameters may be fed by literals or columns selected
   from a parquet file (*SELECT my_udf(COL1, COL2, 123) FROM
   dfs.`path_to_parquet_file`*)
   - Depending on the parameters, the UDF may return NULL.

When I use a Nullable holder such as *NullableVarChar*, I can't pass it a
literal value because the method signature expects an optional value (i.e.
a value from a column that *may* by null, not always having a value such as
a literal)

Remember that the UDF need to have a variable amount of parameters. If this
is not currently possible, I'll have to create multiple UDFs with multiple
amount of parameters and if I do that, I will desperately need a *single*
value holder type that accepts columns, literals, integers and doubles.

My questions are

   1. Is there a value holder that accepts literals & columns for integers
   & doubles ?
   2. Is there a value holder that accepts any kind of input ? Like
   *java.util.Object* in java ?


*---------------------*
*Muhammad Gelbana*
http://www.linkedin.com/in/mgelbana