exosql v0.2.67 ExoSQL.Builtins View Source
Builtin functions.
There are two categories, normal functions and aggregate functions. Aggregate functions receive as first parameter a ExoSQL.Result with a full table, and the rest of parameters are the function calling parameters, unsolved.
These expressions must be first simplified with
ExoSQL.Expr.simplify
and then executed on the rows with
ExoSQL.Expr.run_expr
.
Link to this section Summary
Functions
Returns the first not NULL
sprintf style formatting
Very simple sprintf formatter. Knows this formats
Generates a table with the series of numbers as given. Use for histograms without holes
Gets the domain from the domain name
Get the greatest of arguments
Performs a JSON Pointer search on JSON data
Convert from a string to a JSON object
Get the least of arguments
Returns NULL if both equal, first argument if not
Creates a range, which can later be used in
Performs a regex match
Convert datetime to string
Extracts some keys from each value on an array and returns the array of those values
Parses an URL and return some part of it
Returns to which bucket it belongs
Link to this section Functions
Returns the first not NULL
sprintf style formatting.
Known interpolations:
%d - Integer %f - Float, 2 digits %.Nf - Float N digits %k - integer with k, M sufix %.k - float with k, M sufix, uses float part
Very simple sprintf formatter. Knows this formats:
- %%
- %s
- %d
- %f (only two decimals)
- %.{ndec}f
Generates a table with the series of numbers as given. Use for histograms without holes.
Gets the domain from the domain name.
This means “google” from “www.google.com” or “google” from “www.google.co.uk”
The algorithm disposes the tld (.uk) and the skips unwanted names (.co). Returns the first thats rest, or a default that is originally the full domain name or then each disposed part.
Get the greatest of arguments
Performs a JSON Pointer search on JSON data.
It just uses / to separate keys.
Convert from a string to a JSON object
Get the least of arguments.
Like min, for not for aggregations.
Returns NULL if both equal, first argument if not.
Creates a range, which can later be used in:
IN
— Subset / element contains*
— Interesection -> nil if no intersection, the intersected range if any.
Performs a regex match
May return a list of groups, or a dict with named groups, depending on the regex.
As an optional third parameter it performs a jp query.
Returns NULL if no match (which is falsy, so can be used for expressions)
Convert datetime to string.
If no format is given, it is as to_string, which returns the ISO 8601. Format allows all substitutions from Timex.format, for example:
%d day of month: 00 %H hour: 00-24 %m month: 01-12 %M minute: 00-59 %s seconds since 1970-01-01 %S seconds: 00-59 %Y year: 0000-9999 %i ISO 8601 format %V Week number %% %
Extracts some keys from each value on an array and returns the array of those values
Parses an URL and return some part of it.
If not what is provided, returns a JSON object with:
- host
- port
- scheme
- path
- query
- user
If what is passed, it performs a JSON Pointer search (jp function).
It must receive a url with scheme://server or the result may not be well formed.
For example, for emails, just use “email://connect@serverboards.io” or similar.
Returns to which bucket it belongs.
Only numbers, but datetimes can be transformed to unix datetime.