We do have a way to add custom functions, see edu.caltech.ipac.firefly.server.db.DbCustomFunctions.java
lg was added to custom HSQLDB functions, if(expr, then, else) was not. The reason is that HSQLDB has an equivalent: CASEWHEN(<boolean value expr>, <value expr 2>, <value expr 3>), it can be used from API, like any other HSQLDB function. See http://www.hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html for the list of available functions.
In UI we are supporting a limited subset of HSQLDB functions, because we provide syntax checking. This discrepancy between HSQLDB and our JS Expression Parser is a long standing issue, perhaps there should be an option in UI to turn off column expression syntax checking in chart options.