You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "czzmmc (via GitHub)" <gi...@apache.org> on 2023/04/04 06:57:14 UTC
[GitHub] [doris] czzmmc commented on issue #18343: [Feature] java udf/udaf support columns as function parameters like builtin function PERCENTILE
czzmmc commented on issue #18343:
URL: https://github.com/apache/doris/issues/18343#issuecomment-1495445559
Of course. Image we have a table named t_salary for employees' salary management. And we only have two members. Like blow.
t_salary
```
Alice 100
Bob 200
```
And now we have a Java UDF "cal_bonus" to calculate bonus for them. Here comes our way. The manager wanna set a number depending on how they behave during last year. So for this particular example, the manager would give Alice 300, and Bob 200.
Now, our Java UDAF cal_bonus must take two parameters a rule and a salary column. Like cal_bonus(rule, salary).
SQL: select name, cal_bonus('{"Alice": 300, "Bob":200}', salary) from t_salary;
RESP:
```
name cal_bonus
Alice 400
Bob 400
```
The next year, we could continue to use this Java UDAF with different rule, when we hire more employees.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org