[
https://issues.apache.org/jira/browse/FLINK-6810?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Timo Walther updated FLINK-6810:
--------------------------------
Description:
Umbrella issue for adding scalar functions such as mathematical-function
{{LOG}}, date-functions {{DATEADD}}, string-functions {{LPAD}}, etc.
*How to contribute a built-in scalar function*
Thank you very much for contributing a built-in function. In order to make sure
your contributions are in a good direction, it is recommended to read the
following instructions.
# Investigate the behavior of the function that you are going to contribute in
major DBMSs. This is very important since we have to understand the exact
semantics and type inference of the function.
# It is recommended to add function for both SQL and Table API (Java, Scala,
Python).
# For every scalar function, add corresponding docs which should include a
SQL, a Java/Scala/Python version in
{{./docs/dev/table/functions/systemFunctions.md}}. Make sure your description
of the function is accurate. Please do not simply copy documentation from other
projects, especially if the projects are not Apache licensed.
# Take overflow, handling of NULL, other data types and exceptions into
consideration.
There are different generations of function stacks in the Flink code base. The
newest generation has been added in FLINK-20522 and is the recommended way of
implementing a function similar to a regular user-defined function.
Adding a built-in function requires changes in only 2 classes:
{{BuiltInFunctionDefinitions}} for the definition and the class that contains
the actual runtime logic.
Tests should be added in {{org.apache.flink.table.planner.functions}}.
See the reference implementation of the IFNULL function here:
https://github.com/apache/flink/commit/df46f8948279d1ed89d7113919b4c4f720cf4199
was:
In this JIRA, we will create some sub-tasks for adding specific scalar
functions such as mathematical-function {{LOG}}, date-functions {{DATEADD}},
string-functions {{LPAD}}, etc.
*How to contribute a built-in scalar function*
Thank you very much for contributing a built-in function. In order to make sure
your contributions are in a good direction, it is recommended to read the
following instructions.
# Investigate the behavior of the function that you are going to contribute in
major DBMSs. This is very important since we have to understand the exact
semantics of the function.
# It is recommended to add function for both SQL and table-API (Java and
Scala).
# For every scalar function, add corresponding docs which should include a
SQL, a Java and a Scala version in {{./docs/dev/table/functions.md}}. Make sure
your description of the function is accurate. Please do not simply copy
documentation from other projects, especially if the projects are not Apache
licensed.
# Take overflow, NullPointerException and other exceptions into consideration.
# Add unit tests for every new function and its supported APIs. Have a look at
{{ScalarFunctionsTest}}, {{SqlExpressionTest}},
{{ScalaFunctionsValidationTest}}, etc. for how to implement function tests.
!how to add a scalar function.png!
Welcome anybody to add the sub-task about standard database scalar function.
Note: Usually, adding a runtime function to {{ScalarFunctions.scala}} is
sufficient. However, sometimes it makes sense to implement a {{CallGenerator}}
for {{FunctionGenerator}} to leverage object reuse. E.g., {{HashCalcCallGen}}
creates a {{MessageDigest}} only once for {{SHA2}} if the parameters are
literals.
> Add a set of built-in scalar functions to Table API & SQL
> ---------------------------------------------------------
>
> Key: FLINK-6810
> URL: https://issues.apache.org/jira/browse/FLINK-6810
> Project: Flink
> Issue Type: New Feature
> Components: Table SQL / API
> Affects Versions: 1.4.0
> Reporter: sunjincheng
> Assignee: sunjincheng
> Priority: Major
> Attachments: how to add a scalar function.png
>
>
> Umbrella issue for adding scalar functions such as mathematical-function
> {{LOG}}, date-functions {{DATEADD}}, string-functions {{LPAD}}, etc.
> *How to contribute a built-in scalar function*
> Thank you very much for contributing a built-in function. In order to make
> sure your contributions are in a good direction, it is recommended to read
> the following instructions.
> # Investigate the behavior of the function that you are going to contribute
> in major DBMSs. This is very important since we have to understand the exact
> semantics and type inference of the function.
> # It is recommended to add function for both SQL and Table API (Java, Scala,
> Python).
> # For every scalar function, add corresponding docs which should include a
> SQL, a Java/Scala/Python version in
> {{./docs/dev/table/functions/systemFunctions.md}}. Make sure your description
> of the function is accurate. Please do not simply copy documentation from
> other projects, especially if the projects are not Apache licensed.
> # Take overflow, handling of NULL, other data types and exceptions into
> consideration.
> There are different generations of function stacks in the Flink code base.
> The newest generation has been added in FLINK-20522 and is the recommended
> way of implementing a function similar to a regular user-defined function.
> Adding a built-in function requires changes in only 2 classes:
> {{BuiltInFunctionDefinitions}} for the definition and the class that contains
> the actual runtime logic.
> Tests should be added in {{org.apache.flink.table.planner.functions}}.
> See the reference implementation of the IFNULL function here:
> https://github.com/apache/flink/commit/df46f8948279d1ed89d7113919b4c4f720cf4199
--
This message was sent by Atlassian Jira
(v8.3.4#803005)