v.io: v.io/v23/query/engine/internal/queryfunctions Index | Files

package queryfunctions

import "v.io/v23/query/engine/internal/queryfunctions"

Package queryfunctions describes SyncQL's built-in functions.

This package is called by the query_checker package to check that a function exists and is being passed the correct number of arguments and, if possible, the correct types of arguments. If the function can be executed at check time (because the function has no args or because the args are all literals (or (recursively) other functions that can be executed at check time), the function is executed at check time and the result of the function is subsituted for the function in the AST.

If the function cannot be executed at check time, it is executed by the query package once for each candicate row (in the case of function calls in the where clause) or selected row (in the case of function calls in the select clause).

It is expected that functions will be grouped in some way into separate files (e.g., string functions are in str_funcs.go).

Functions must be listed in the functions map in query_functions.go. Each entry is a function struct which contains the following fields:

argTypes []query_parser.OperandType

The arguments expected.  If the argument count is wrong,
the checker will produce an error.  The types are
informational only as the function itself is required
to attempt to coerce the args to the correct type or
return an error.

hasVarArgs bool

True if, in addition to any types listed in argTypes, the function
can take additional (optional) args.

varArgsType The type of the additional (optional) args. returnType query_parser.OperandType

The return type of the function, for informational purposes

funcAddr queryFunc

The address of the query function.
If the function cannot complete to success, it must return an error and the
argument responsible for the error.

checkArgsAddr checkArgsFunc

The address of a function to check args at checker time.
This function should check any arguments that it can at checker time.
It can check literals.  Note: if all args are literals, the function itself
is called at checker time rather than this function.
DO NOT sepecify a checkArgsAddr if all that is to be checked is the number
and types of args. These checks are standard.


Package Files

date_funcs.go doc.go math_funcs.go obj_funcs.go query_functions.go str_funcs.go

func CheckFunction Uses

func CheckFunction(db ds.Database, f *queryparser.Function) error

Check that function exists and that the number of args passed matches the spec. Call query_functions.CheckFunction. This will check for, to the extent possible, correct types. Furthermore, it may execute the function if the function takes no args or takes only literal args (or an arg that is a function that is also executed early). CheckFunction will fill in arg types, return types and may fill in Computed and RetValue.

func ConvertFunctionRetValueToRawBytes Uses

func ConvertFunctionRetValueToRawBytes(o *queryparser.Operand) *vom.RawBytes

func ExecFunction Uses

func ExecFunction(db ds.Database, f *queryparser.Function, args []*queryparser.Operand) (*queryparser.Operand, error)

func FuncCheck Uses

func FuncCheck(db ds.Database, f *queryparser.Function, args []*queryparser.Operand) error

Package queryfunctions imports 15 packages (graph) and is imported by 4 packages. Updated 2020-10-29. Refresh now. Tools for package owners.