Package edu.caltech.nanodb.functions

This package contains the abstractions for supporting simple functions, aggregate functions, and table-returning functions in NanoDB. Additionally, this package contains many function implementations to use in SQL queries, as well as a FunctionDirectory for looking up function implementations from within the query planning and evaluation code.

Here is a brief description of the abstractions implemented in NanoDB.

  • All kinds of functions derive from the abstract Function base class.
  • "Simple functions" take zero or more arguments, and produce one result for each set of inputs. They may be deterministic or nondeterministic, and they may access or maintain state data. All simple functions derive from the SimpleFunction class.
  • "Aggregate functions" take a multiset of inputs, and produce one aggregate result from that multiset of inputs. Currently, aggregate functions only accept one multiset (e.g. AVG(n)). All aggregate functions derive from the AggregateFunction class.
  • Both simple functions and aggregate functions derive from the ScalarFunction class, since both of them return a single result value, and both can appear in expressions.
  • "Table functions" take zero or more arguments, and return a result-set of zero or more tuples. Table functions have an interface similar to the plan-node interface so that tuples can be produced one at a time, and other details such as schema and costing details can be exposed by the function.

Function Naming

All function names are uppercase.

Aggregate functions may support the DISTINCT keyword, e.g. "SELECT COUNT(DISTINCT a) FROM t;". In NanoDB, these invocations are mapped to a function invocation with "#DISTINCT" appended to the specified function name. For example, the example SQL will result in NanoDB resolving the invocation to the "COUNT#DISTINCT" function.