Learn good practices for creating user-defined functions.
- Do not write ambiguous code, or constructs that can unexpectedly loop
forever, without providing a mechanism for the user to cancel the UDF invocation
(see the function 'get_is_cancelled()'.
- Do not perform complex, or memory-intensive operations that are
repeated every invocation. When a UDF call is made against a table that contains
many thousands of rows, efficient execution becomes paramount. Allocate blocks of
memory for a thousand to several thousand rows at a time, rather than on a
row-by-row basis.
- Do not open a database connection, or perform database operations
from within a UDF. All parameters and data required for UDF execution must be passed
as parameters to the UDF.
- Do not use reserved words when naming UDFs.
Note: Use source
control software for C++ UDFs and Java UDFs to track changes to:
- The source code (.java files/.cpp
files)
- The class/jar/dll/so files that may be deployed to the
database or mentioned in the UDF stored procedure definition.
- The Syntax for the UDF stored procedure definition itself.
- Deployment instructions, 3rd party library versions and special deployment notes
such as security specifics.