Help Center/
DataArts Fabric/
Developer Guide/
Data-AI Convergence/
DataArts Fabric DataFrame/
Registering a Scalar UDF Using the DataFrame API/
Implicitly Registering a Scalar UDF
Updated on 2025-09-18 GMT+08:00
Implicitly Registering a Scalar UDF
Implicitly register Scalar UDFs, which relies on the Python runtime to automatically discover and register Scalar UDFs. For detailed usage, refer to Scalar UDF Implicit Registration Syntax.
- For Scalar Python UDFs, registering a Scalar Python UDF involves registering an original Python function into the database. The example code for implicit registration is as follows. For parameter descriptions, refer to Scalar Python UDF Registration Parameters.
- Example of implicitly registering a Python function for a scalar Python UDF
import ibis_fabric as fabric from ibis_fabric.udf import RegisterType # Implicitly register a UDF. @fabric.udf.python(database="your-database", register_type=RegisterType.OBS) def calculate_product(price: float, quantity: int) -> float: return price * quantity # Use the UDF. con = ibis.fabric.connect(...) t = con.table("your-table", database="your-database") expression = t.select(calculate_product(t.price, t.quantity).name("product column")) print(expression.execute())
- Example of implicitly registering a Python class for a scalar Python UDF
import ibis import ibis_fabric as fabric from ibis_fabric.udf import RegisterType # Implicitly register a UDF. @fabric.udf.python(database="your-database", register_type=RegisterType.OBS) class Hello: def __init__(self, firstname: str, lastname: str): self.firstname = firstname self.lastname = lastname def process(self, location: str) -> str: return f"Hello{self.firstname} {self.lastname}! Welcome to {location}" # Use the UDF. con = ibis.fabric.connect(...) t = con.table(name="your-table", schema="your-schema") expression = t.select(Hello(t.city).with_arguments(firstname="Ethan", lastname="Carter")) print(expression.execute())
- Example of implicitly registering a Python function for a scalar Python UDF
- For Scalar Builtin UDFs, registering a Scalar Builtin UDF serves to obtain the handle of an existing function in the database. There is no actual registration operation. The example code for implicit registration is as follows. For parameter descriptions, refer to Scalar Builtin UDF Registration Parameters.
- Example of implicitly registering a Python function for a scalar builtin UDF
import ibis import ibis_fabric as fabric # Implicitly register a UDF. The power function already exists in the database. @fabric.builtin.python(database="your-database") def power(a: float, b: float) -> float: ... # Use the UDF. con = ibis.fabric.connect(...) t = con.table("your-table", database="your-database") expression = t.select(power(t.interest, t.interval).name("yield column")) print(expression.execute())
- Example of implicitly registering a Python class for a scalar builtin UDF
import ibis import ibis_fabric as fabric # Implicitly register a UDF. The Power class already exists in the database. @fabric.builtin.python(database="your-database") class Power: def __init__(self, base: float): ... def process(self, exp: float) -> float: ... # Use the UDF. con = ibis.fabric.connect(...) t = con.table("your-table", database="your-database") expression = t.select(Power(t.interval).with_arguments(base=1024.0).name("yield column")) print(expression.execute())
- Example of implicitly registering a Python function for a scalar builtin UDF
Parent topic: Registering a Scalar UDF Using the DataFrame API
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.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot