You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New SQL functions are usually one of the most proper parts for newcomers to try to participate in Doris' development. For future reference, we'd like to list the basic processes for implementing a new function in Doris.
What to do
To implement a new SQL function, here's what you need to write in your PR:
The function implementation and registration in BE
The function signature and visitor for nereids planner in FE
btw: You may see some PR modified doris_builtin_functions.py. Now we don't need it anymore.
Key Points
BE Implementations
Use the base template when you try to implement a date/arithmetic calculation. You can find them by searching for other similar functions.
Execution speed is very, very important for Doris. Therefore, you must eliminate all unnecessary copies and calculations. Try to use raw operations on inputs and outputs. If you can use the output Column's memory to receive the calculation result, do not add another variable and copy them. Don't call any virtual function in a loop. If it's necessary, use the template to generate different function entities to eliminate type judgment.
FE Signature
Most functions use one of the following interfaces:
AlwaysNullable means the function's return type is always wrapped in Nullable. Use it when the function may generate the null value for not-null input.
AlwaysNotNullable means the function's return type is never wrapped in Nullable. Use it when the function changes all the null input to a not-null output.
PropagateNullable: when the input columns contain at least one Nullable column, the output column is Nullable. otherwise not. When you calculate the result for a not-null value and leave null alone, it's the right choice.
New SQL functions are usually one of the most proper parts for newcomers to try to participate in Doris' development. For future reference, we'd like to list the basic processes for implementing a new function in Doris.
What to do
To implement a new SQL function, here's what you need to write in your PR:
functions/executable/NumericArithmetic.java
.test_template_{X}_arg(s).groovy
in https://github.com/apache/doris/pull/47307/files (maybe updated. So find the newest version in master branch)You could refer to https://github.com/apache/doris/pull/47307/files as a complete example(only missing FE constant folding)
btw: You may see some PR modified
doris_builtin_functions.py
. Now we don't need it anymore.Key Points
BE Implementations
FE Signature
Most functions use one of the following interfaces:
AlwaysNullable
means the function's return type is always wrapped inNullable
. Use it when the function may generate thenull
value for not-null input.AlwaysNotNullable
means the function's return type is never wrapped inNullable
. Use it when the function changes all thenull
input to a not-null output.PropagateNullable
: when the input columns contain at least oneNullable
column, the output column isNullable
. otherwise not. When you calculate the result for a not-null value and leavenull
alone, it's the right choice.Testcase
The testcases' type and quantities must not be less than the corresponding files in https://github.com/apache/doris/pull/47307/files.
The data you use must cover all the borders of its datatype and other sensitive values.
Add BE-UT case with
check_function_all_arg_comb
interface to cover Const-combinations.You can run the cases using the scripts
run-regression-test.sh
andrun-be-ut.sh
. They have details explanations in them.Other Advice
The text was updated successfully, but these errors were encountered: