beanquery icon indicating copy to clipboard operation
beanquery copied to clipboard

Alternative way to handle NULLs

Open dnicolodi opened this issue 3 years ago • 0 comments
trafficstars

When the development focus will switch to performance, we may investigate an alternative way of handling NULL values. Instead than bubbling up NULLs through the BQL call stack, we can simply raise a dedicate exception, rewinding the stack up till the first function that handles it. This has the advantage of removing the code that check function arguments for None and will only require to replace all return None into raise NullValue. The implementation of functions that handle NULL values will just have to wrap arguments evaluation with something like:

def maybenull(x, context):
    try:
        return x(context)
    except NullValue:
        return None

dnicolodi avatar Apr 05 '22 18:04 dnicolodi