Thanks!!

On 2021/07/14 02:26:47, JING ZHANG <beyond1...@gmail.com> wrote: 
> Hi, Shamit Jain,
> In fact, it is an optimization to simplify expression.
> If a Udf has no parameters, optimizer would be look it as an expression
> which always generate constants results.
> So it would be calculated once in optimization phase instead of run by per
> record in. runtime phase.
> 
> The optimization would be disabled if any of the following condition is
> satisfied:
> (1) Expression has at least one parameter
> (2) Udf is not deterministic.(default value of `isDeterministic` is true,
> you could change the behavior by override the metjod `isDeterministic` of
> FunctionDefinition)
> (3) Udf is a dynamic function. (not applied for UDF, it is used for flink
> built-in SqlOperator).
> 
> Best,
> JING ZHANG
> 
> 
> shamit jain <jainsha...@gmail.com> 于2021年7月14日周三 上午3:00写道:
> 
> > 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