Skip to content

mkio 1.5.0

Choose a tag to compare

@markuskimius markuskimius released this 20 Sep 19:30
· 1 commit to main since this release

mkio 1.5.0 moves the expression language to version 2: word operators, in, duration literals, COUNT and function forms of the aggregates. A minor release: every version-1 expression means what it did, since each addition gives meaning to text that was a syntax error. No change to config, the wire protocol, the CLI or the on-disk layout.

Added — language (Python and /mkio-expr.js, pinned by 95 new shared cases)

  • and, or, not, in, not in, case-insensitive. They are contextual, not reserved: a bare word is an operator only where the grammar had no use for a name, so fields called in or not parse as they always did. not has Python's precedence, between and and the comparisons, so not a > b negates the comparison where !a > b is a type error.
  • x in y is CONTAINS(y, x): member of an array, substring of a string, key of a map, FALSE for NULL. It sits with the comparisons and, like them, does not chain.
  • Duration literals 500ms 2s 1.5m 1h 1d evaluate to seconds, so durations add, scale and compare like any number.
  • COUNT(xs, fn) (without fn, the non-NULL elements), and function forms of the aggregates: SUM(trades, t -> t.qty), likewise AVG, MIN, MAX. The list-only and varargs forms are unchanged.

Added — host tools (Python only)

  • parse_prefix(text, pos, stop=) parses the one expression that starts at text[pos] and returns it with the offset where it ended, for grammars that embed expressions between their own keywords. stop=["or timeout"] names phrases that end the expression where a word operator would continue it.
  • field_paths(ast) lists every dotted path read from the scope, resolving lambda parameters and LET names (MAP(trades, t -> t.px) reads trades.*.px); check_fields(ast, schema) returns every path the schema does not know. A missing key is NULL at run time, so a misspelt column fails silently; this finds it first.
  • register_library(..., default=False) keeps a library out of every environment that does not name it; Env(extra=[...]) adds it to the defaults.

Changed

  • LANGUAGE_VERSION moves from "1" to "2", and the _mkio reply's expr with it. The compatibility check compares expr exactly, as before: a client that asks for language 1 is told it no longer matches. mkui vendors the JavaScript file and the cases and follows in 1.10.0.
  • NOT is refused as a function name, since not (x) is the operator.
  • A plain pytest now tests the source tree whatever mkio is installed.

See the README section on the expression language and its generated function tables.