Skip to content

Latest commit

 

History

History
30 lines (18 loc) · 1.09 KB

user-defined-functions-udf.md

File metadata and controls

30 lines (18 loc) · 1.09 KB

User Defined Functions (UDF)

Runtime UDF Support

The Remote Backend Compiler (RBC) package implements the OmniSciDB client support for defining so-called Runtime UDFs. That is, while OmniSciDB server is running, one can register new SQL functions to Omnisci Calcite server as well as provide their implementations in LLVM IR string form. The RBC package supports creating Runtime UDFs from Python functions.

A User-Defined Function brings the capability of defining new SQL functionalities that work in a rowwise fashion manner. The figure below illustrates how a UDF works:

function add1 is called for every row and produce a new row

Example

First, we need to connect RBC to Omnisci server using the RemoteOmnisci remote class.

from rbc.omniscidb import RemoteOmnisci
omnisci = RemoteOmnisci(user='admin', password='HyperInteractive',
                        host='127.0.0.1', port=6274, dbname='omnisci')

One can define UDF functions using omnisci as a decorator:

@omnisci('int32(int32)')
def incr(i):
    return i + 1