Package gavo :: Package adql :: Module ufunctions
[frames] | no frames]

Module ufunctions

source code

"User" defined functions, i.e., ADQL functions defined only on this system.

See the userFunction docstring on how to use these.

Classes
  UserFunction
A node processing user defined functions.
Functions
 
userFunction(name, signature, doc, returntype='double precision', unit='', ucd='')
a decorator adding some metadata to python functions to make them suitable as ADQL user defined functions.
source code
Variables
  UFUNC_REGISTRY = {'GAVO_HISTOGRAM': <__builtin__.function obje...
  __package__ = 'gavo.adql'
Function Details

userFunction(name, signature, doc, returntype='double precision', unit='', ucd='')

source code 
a decorator adding some metadata to python functions to make
them suitable as ADQL user defined functions.

name is the name the function will be visible under in ADQL; signature is a
signature not including the name of the form '(parName1 type1, parName1
type2) -> resulttype'; doc is preformatted ASCII documentation.  The
indentation of the second line will be removed from all lines.

returntype is the SQL return type, which defaults to double
precision.  While ADQL 2.0 appears to say that UDFs must be
numeric, in practice nobody cares; so, return whatever you see fit.

unit and ucd are optional for when you actually have a good guess what's
coming back from your ufunc.  They can also be callable; in that
case, they'll be passed the (annotated) arguments, and whatever
they return will be the unit/ucd.

The python function receives an array of arguments; this will in
general be ADQL expression trees.  It must return either 

* a string that will go literally into the eventual serialised SQL 
  string (so take care to quote; in general, you will use 
  nodes.flatten(arg) to flatten individual args); 
* or they may return None, in which case the expression tree
  remains unchanged.  This is for when the actual implementation is
  in the database.
* or they may return a nodes.ADQLNode instance, which then replaces
  the user defined function in the parse tree and will be annotated
  as usual.

If you receive bad arguments or something else goes awry, raise
a UfuncError.


Variables Details

UFUNC_REGISTRY

Value:
{'GAVO_HISTOGRAM': <__builtin__.function object>,
 'GAVO_IPIX': <__builtin__.function object>,
 'GAVO_MATCH': <__builtin__.function object>,
 'GAVO_SIMBADPOINT': <__builtin__.function object>,
 'GAVO_TO_JD': <__builtin__.function object>,
 'GAVO_TO_MJD': <__builtin__.function object>,
 'GAVO_TRANSFORM': <__builtin__.function object>,
 'IVO_APPLY_PM': <__builtin__.function object>,
...