SkySpark by SkyFoundry

6. Axon


Axon is a programming language used for scripting within SkySpark. Most functionality can be accessed through Axon:

One of the pivotal features of SkySpark is that all queries to the database/analytics engine are full Axon expressions:

// find all the records with kw tag

// same as above

// find all recs with kw and read history data for yesterday

// find peak kW for yesterday for all kw recs
readAll(kw).hisRead(yesterday).hisRollup(max, 1day)

This design allows great flexibility scaling up from simple queries to powerful data transformation pipelines - all using a single general purpose syntax.

Language Overview

Axon is a full general purpose programming language characterized as follows:

Axon draws inspiration from Fantom, Lisp, Ruby, Scala, and Haskell. Experienced programmers should be able to pick up Axon very quickly, however, a grounding in functional programming will definitely help.

The Axon Language chapter digs into the syntax of the Axon language.

Func Recs

Function records define new top-level functions with the following tags:

Top-Level Namespace

The top-level namespace of a project is defined by:

  1. core functions
  2. named func records
  3. extensions installed by the project

The following functions are useful for working with the top-level function namespace:

Qualified Names

The name used in a function call can be either qualified or unqualified. Qualified functions specify an explicit library namespace using double colons:

equip::toPoints  // qualified in "equip" ext namespace
core::toHex      // core functions live in "core" namespace

Unqualified function names are resolved by the implicit namespace which is searched in this order:

  1. local namespace of function (parameter/variable names)
  2. func records
  3. extensions installed by project

Function Overrides

If an ext function is tagged as overridable, then you can override it by declaring a function record with the same name. Functions resolved as a project rec take priority over the function defined by the extension.

Attempts to override an ext function not marked as overridable will report an error and your rec function will not be accessible. For testing you can disable these checks on a per project basis by adding the marker tag disableOverridableChecks to the projMeta record.

You can access the built-in function in your override using its qualified name:

geoTz(val) => do
  // handle special case
  if (val["geoCountry"] == "RU") return "Moscow"

  // route back to built-in version
  return geo::geoTz(val)