Overview
Registering a Scalar UDF involves including the specified UDF in the backend database and returning a UDF operator that can be manipulated within the Ibis DataFrame after registration.
The value returned by registering a Scalar UDF is a UDF operator in the DataFrame. This UDF operator can subsequently be invoked multiple times by various DataFrame expressions.
Overall, registering a Scalar UDF can be done in two ways: explicit registration and implicit registration.
Registration Method |
Description |
Dependent on Session Object |
Intrusively Add Registration Logic |
Use Case |
Helpful Link |
---|---|---|---|---|---|
Explicit registration |
Code explicitly specifies the registration information of the Scalar UDF. |
Yes |
Yes |
If you wish to precisely control the registration timing, allow intrusive addition of registration logic, or require separation between registration and usage of Scalar UDFs under the same backend connection. |
|
Implicit registration |
Automatically discovers and registers Scalar UDFs during runtime. |
No |
No |
If you prefer non-intrusive registration of Scalar UDFs and do not require separation between registration and usage of Scalar UDFs under the same backend connection. |
Whether using explicit or implicit registration, the meaning of registration differs depending on the Scalar UDF type. Details are provided in the table below.
Scalar UDF Type |
Meaning |
Helpful Link |
---|---|---|
python |
Registers a raw Python function or class into the database. |
|
builtin |
Obtains the handle of an existing function in the database; no actual registration operation is performed. |
If a Python class is passed during registration, the __init__, process, and __del__ instance methods have specific semantic interpretations. Details can be found in the table below. There are no restrictions on other Python classes or instance methods, allowing users to freely add them.
Python Class Method |
Mandatory |
Parameter |
Description |
Use Case |
---|---|---|---|---|
__init__(self, *args, **kwargs) |
No |
Parameters are passed through the with_arguments method. Only scalar values are allowed. |
Constructor of the UDF. |
Initializes UDF attributes (such as saving parameters, opening files, and establishing connections). |
process(self, *args, **kwargs) |
Yes |
Parameters are passed through the UDF operator. Both scalar values and column names are allowed. |
Entry point for the service logic of the UDF. |
Processes data and performs calculations in the UDF. |
__del__(self) |
No |
Does not support passing parameters. |
Destructor of the UDF. |
Clears UDF resources (for example, closing files and disconnecting networks). |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot