Skip to content

v2.2.0: Five more databases, metric names everywhere, per-column labels

Latest

Choose a tag to compare

@ZmeiGorynych ZmeiGorynych released this 02 Dec 21:20
bc88371

SLayer 2.2.0

SQL queries over your semantic model, typed connections for five more databases, metric names that work anywhere their expression does, correct column labels, and a long list of query shapes that now run instead of being refused.

SLayer SQL

You can now query your semantic model in SQL from Python. engine.execute_slayer_sql(...) (or execute_slayer_sql_sync) runs an ordinary SQL statement over your datasets, where each dataset's metrics are measure columns you evaluate with AGG(m): SELECT deptno, AGG(sum_sal) AS payroll FROM emp WHERE job <> 'CLERK' GROUP BY deptno. It implements Ossie's Layer 2 query interface and by default also accepts native SLayer forms such as bare measures, cumsum and relationship paths; pass conformance="ossie-l2" to accept strict Layer 2 only. Joins, ROLLUP / CUBE, UNION and subqueries inside expressions are not supported yet, and MCP, REST and the CLI do not take SLayer SQL yet. See the SLayer SQL page in the docs.

Databricks, Oracle, Athena, Presto and Spark

You can now connect to Databricks, Oracle, Athena, Presto and Spark by filling in typed fields on your datasource (host, http_path, service_name, region, catalog and so on) instead of writing a connection string. Each has its own install extra, for example pip install "motley-slayer[oracle]", and [all] includes them. Missing or conflicting fields are reported when you save the datasource, naming the fields but never their values.

With tls: true these connections always verify the server's certificate, against your ca_certificate if you give one. Connecting is bounded by 30 seconds unless you set connect_timeout, and a refused or reset connection is retried within that limit. Databricks can sign in with a service principal, Athena never falls back to the server's own AWS identity, and on Oracle schema_name becomes the current schema. A duckdb or sqlite datasource with no database is now an in-memory database, and two such DuckDB datasources no longer share one. See the Datasources page for each type's fields.

Queries

A saved metric's name now works wherever its expression does: in filters, order keys, partition_by=, inside other aggregations (sum(customers.aov)) and in downstream stages.

Several shapes that used to be refused now run:

  • a filter comparing a row to an aggregate, such as amount > avg(amount, partition_by=region);
  • an aggregate as a time dimension, so a cohort query (orders grouped by the month of each customer's first order) works;
  • a partition_by= key the grain already determines, such as lower(orders.city) beside orders.city, or the year beside a month time dimension;
  • window= and FILTER (WHERE ...) on the outer aggregation of an aggregation over aggregates, and both together everywhere;
  • a weight or ranking key combining several aggregates in an aggregation over aggregates;
  • a query without population whose dimensions come from datasets no relationship connects: each metric is computed where its dataset reaches and repeated across the rest, per to_many_handling.

Each column of a query response now has its own label and description: the one you give in the query, else the saved metric's, else the field's only for min, max, first, last and percentile_disc. Listing the same saved metric twice no longer fails.

Fixes

A re-aggregation inside a computed dimension no longer fails beside a metric read across a relationship, and no longer double-counts across a one-to-many join. Transforms inside an aggregation beside another dataset's aggregate return their standalone values instead of wrong values or crashes, and a second-order metric over two datasets no longer drops rows only one of them supplies. max(change(...)) and similar no longer crash. Window functions that Snowflake or BigQuery reject are now rewritten to equivalent SQL or refused with a clear error. Generated SQL no longer computes the same subquery twice.

The MCP server now advertises a title, description and icon, and every tool has a title and read-only / destructive hints.

Behaviour changes to check

  • Response labels: count(id), sum(x) and other aggregations no longer inherit the field's label.
  • A total or partitioned metric beside a filter on an aggregate-based computed dimension now reads the filtered rows.
  • An aggregation over aggregates at the same grain as its operand (such as max(coalesce(sum(items.qty), 0))) returns the operand's value in cells with no rows, instead of NULL.
  • A structured presto, athena, databricks, spark or oracle datasource no longer builds a generic <type>:// URL. A raw Athena URL without both keys, and a Spark or Presto HTTPS URL that skips certificate checks, are refused. ca_certificate together with a connection_string on Databricks or Athena is refused.
  • Every Oracle transaction SLayer opens is read-only.
  • A datasource with neither type nor connection_string raises a SLayer error instead of TypeError.