Added support for sql functions

/cc @sshillo @ciniglio 

Allows callers to use arbitrary sql functions