exosql v0.2.46 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.executor.simplify_expr_columns and then executed on the rows with ExoSQL.Expr.run_expr.

Link to this section Summary

Link to this section Functions

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

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_, step) 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.

Performs a JSON Pointer search on JSON data.

It just uses / to separate keys.

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, regexs, query) 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 %% %

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.