Skip to content

Table Extensions ​

An extension is a named JSON descriptor on a registered table. It switches optional behaviour on. It changes neither the data nor the schema of the table. Beacon stores an extension with the table. It survives a restart.

Beacon has one extension today:

  • preset: define named filter sets. Other features use them by name.

Manage extensions ​

Set, inspect and remove an extension with SQL DDL. The admin REST API gives the same functions. The value is a JSON object. Each extension has its own shape.

sql
-- Attach or replace an extension
SET EXTENSION '<name>' FOR <table> TO '<json>';

-- List the extensions on a table
SHOW EXTENSIONS FOR <table>;

-- Remove an extension
DROP EXTENSION '<name>' FOR <table>;

Beacon parses the payload strictly. It rejects an unknown key and an invalid value. It does not ignore them. A spelling error therefore gives an error. It does not switch the feature off in silence.

The preset extension ​

A preset is a named filter set on the table. A preset gives a caller a short name for a common query. The caller picks shallow instead of the full filter.

sql
SET EXTENSION 'preset' FOR obs TO '{
  "presets": [
    {
      "name": "shallow",
      "description": "Surface layer only",
      "filters": [{"column": "depth", "op": "<=", "value": 10}]
    },
    {
      "name": "north_atlantic",
      "description": "North Atlantic basin",
      "filters": [
        {"column": "lat", "op": ">=", "value": 0},
        {"column": "lat", "op": "<=", "value": 70}
      ]
    }
  ]
}';

Each preset has a name, a description and a list of filters. The description says what the preset selects. A filter is {"column", "op", "value"}. Beacon combines the filters of one preset with AND.

See also ​

Released under the AGPL-3.0 License.