exosql v0.2.72 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

Link to this function call_function(name, params) View Source

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
Link to this function format(str, arg1, arg2, arg3) View Source
Link to this function format(str, arg1, arg2, arg3, arg4) View Source
Link to this function format(str, arg1, arg2, arg3, arg4, arg5) View Source
Link to this function format(str, arg1, arg2, arg3, arg4, arg5, arg6) View Source
Link to this function format(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7) View Source
Link to this function format(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) View Source
Link to this function format(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) View Source

Generates a table with the series of numbers as given. Use for histograms without holes.

Link to this function generate_series(start_, end_) View Source
Link to this function generate_series(start_, end_, days) View Source

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)

Link to this function regex(str, regex, captures) View Source

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

Link to this function unnest(array, col1, col2) View Source
Link to this function unnest(array, col1, col2, col3) View Source
Link to this function unnest(array, col1, col2, col3, col4) View Source
Link to this function unnest(array, col1, col2, col3, col4, col5) View Source
Link to this function unnest(array, col1, col2, col3, col4, col5, col5) View Source
Link to this function unnest(array, col1, col2, col3, col4, col5, col5, col6) View Source
Link to this function unnest(array, col1, col2, col3, col4, col5, col5, col6, col7) View Source
Link to this function unnest(array, col1, col2, col3, col4, col5, col5, col6, col7, col8) View Source

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.

Link to this function width_bucket(n, start_, end_, nbuckets) View Source

Returns to which bucket it belongs.

Only numbers, but datetimes can be transformed to unix datetime.