heavyai / rbc

Remote Backend Compiler
https://rbc.readthedocs.io
BSD 3-Clause "New" or "Revised" License
29 stars 10 forks source link

Support `require` keyword on RBC #365

Open guilhermeleobas opened 2 years ago

guilhermeleobas commented 2 years ago

The require keyword was merged on https://github.com/omnisci/omniscidb-internal/pull/5955. The require keyword adds a set of constraints that need to be satistified for the table function to execute. It is likely that, to support it from RBC, this feature will require some modifications to the OmniSciDB codebase. Right now, require checks are C++ functions generated at compile time when the server is compiled. The syntax should be the same currently used in the server.

@omnisci('int32_t(Column<T>, int i | require="i > 0", Constant<1>, OutputColumn<T>)', T=['int32_t'])
def udtf(x, i, y):
    y[0] = 123
    return 1
pearu commented 2 years ago

I think rbc should generate two LLVM IR functions, udtf and udtf__require_check, if require annotations are used. With this approach, omniscidb server might need no changes.

When used from rbc, the semantics of the require annotation would be:

require='<almost any Python boolean expression>'

rbc would generate a Python function that is numba.cfunc-ed to udtf__require_check.