Hi!

You should override the isDeterministic() method and return false. The
default return value of this method is true.

>From the java doc of this method:

> Furthermore, return false if the planner should always execute this
> function on the cluster side. In other words: the planner should not
> perform constant expression reduction during planning for constant calls to
> this function.


shamit jain <jainsha...@gmail.com> 于2021年7月14日周三 上午2:56写道:

> Hi,
>
> I am facing an issue where scalar UDF called once in case if no parameter
> passed as given below:-
>
> public class DateTimeToEpochUDF extends ScalarFunction {
> public Long eval() {
>                 System.out.print("Test");
>                 return Instant.now().toEpochMilli();
>         }
> }
>
> Now if I run the below query I will get the same time, looks like the
> function is called only one time, as the SOP also not printed.
>
> select DateTimeToEpochUDF(), employee_ID from Employee;
>
> Please note if I passed the parameter in UDF like primary key it is called
> separately for each record of employee.
>
> Request you to please let me know if I am doing something wrong.
>
> regards,
> Shamit Jain
>

Reply via email to